File:MDKQ 3D.svg

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file(SVG file, nominally 405 × 374 pixels, file size: 64 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary[edit]

Description
Deutsch: Fit einer 2D-Funktion
Date
Source Own work
Author Christian Schirm
Quellen
InfoField
Skript zur Bildgenerierung Erzeugungsskript, um die Grafik zu erstellen
Anleitung
InfoField
Benötigte Open-Source-Software:

Nach der Installation von Python den Quelltext in eine Datei mdkq.py kopieren und starten durch Doppelklicken oder in der Konsole durch Eingabe von

python mdkq.py
SVG development
InfoField
 
The SVG code is valid.
 
This plot was created with Matplotlib.
Source code
InfoField

Python code

from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy

numpy.random.seed(3)
nMess = 18
x0 = numpy.random.rand(nMess)
x0 = x0-min(x0); x0 *= 10 / max(x0)
x1 = numpy.random.rand(nMess)*10
x1 = x1-min(x1); x1 *= 10 / max(x1)
y = numpy.random.randn(nMess)*10
x = numpy.array(list(zip(x0,x1)))

def base(x0, x1, n):
    return numpy.array([x0**i0.ravel() * x1**i1.ravel() for i0, i1 in numpy.mgrid[:n,:n].reshape(2,n*n).T]).T

nBasisProAchse = 3

A = base(x0, x1, nBasisProAchse)
c = numpy.linalg.inv(A.T @ A) @ A.T @ y

yModell = A @ c

x0neu, x1neu = numpy.meshgrid(numpy.linspace(0, 10, num=20), numpy.linspace(0, 10, num=20))
yneu = base(x0neu, x1neu, nBasisProAchse) @ c

fig = plt.figure(figsize=(4.5,4.5))
ax = fig.add_subplot(111, projection='3d')
p2 = ax.plot_wireframe(x1neu, x0neu, yneu, color='r', rstride=1, cstride=1, label='Modellfunktion', linewidth=1, zorder=0)
p1 = ax.scatter(x0, x1, y, label='Messpunkte', zorder=2)
for i in range(len(y)):
    ax.plot([x0[i]]*2, [x1[i]]*2, [y[i], yModell[i]], color='#60c060', linewidth=1.5, label='Residuum' if i==0 else None, zorder=1)
lx0 = ax.set_xlabel('x1')
lx1 = ax.set_ylabel('x2')
ly = ax.set_zlabel('y')
leg = plt.legend(frameon=True)
plt.tight_layout()
plt.show()
plt.savefig('MDKQ_3D.svg')

Licensing[edit]

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current12:22, 23 May 2021Thumbnail for version as of 12:22, 23 May 2021405 × 374 (64 KB)Physikinger (talk | contribs)Legend order
12:05, 23 May 2021Thumbnail for version as of 12:05, 23 May 2021405 × 374 (64 KB)Physikinger (talk | contribs)New Matplotlib version
21:17, 7 April 2011Thumbnail for version as of 21:17, 7 April 2011381 × 353 (183 KB)PhysikingerC (talk | contribs)border
21:15, 7 April 2011Thumbnail for version as of 21:15, 7 April 2011412 × 381 (183 KB)PhysikingerC (talk | contribs)border
21:05, 7 April 2011Thumbnail for version as of 21:05, 7 April 2011366 × 337 (182 KB)PhysikingerC (talk | contribs)background
21:02, 7 April 2011Thumbnail for version as of 21:02, 7 April 2011359 × 336 (182 KB)PhysikingerC (talk | contribs)white Background
20:59, 7 April 2011Thumbnail for version as of 20:59, 7 April 2011359 × 336 (182 KB)PhysikingerC (talk | contribs)== Summary == {{Information |Description ={{de|1=Fit einer 2D-Funktion}} |Source ={{own}} |Author =Chrischi |Date =2011-04-07 |Permission = |other_versions = }}

The following page uses this file:

File usage on other wikis

The following other wikis use this file:

Metadata