File:MDKQ2.svg

Uploaded by Physikinger
Upload date 2021-05-23T12:07:47Z
MIME type image/svg+xml
Dimensions 378 × 288 px
File size 33.6 KB

Summary

Description
Deutsch: Fit einer linearen Funktion
Date
Source Own work, Neufassung von File:Streudiagramm_Kriegsschiffe.png vom Benutzer Philipendula
Author PhysikingerC
SVG development
InfoField
 The SVG code is valid.
 This plot was created with Matplotlib.
Source code
InfoField

Python code

# This source code is public domain

import numpy, pylab
import matplotlib.pyplot as plt

x = [208, 152, 113, 227, 137, 238, 178, 104, 191, 130]
y = [21.6, 15.5, 10.4, 31.0, 13.0, 32.4, 19.0, 10.4, 19.0, 11.8]
N = 2
A = numpy.zeros((N,N))
for i in range(N):
    for j in range(N):
        A[i,j]=sum(xi**(i+j) for xi in x)
b = numpy.zeros((N))
for i in range(N):
    b[i]=sum(xi**(i)*yi for xi,yi in zip(x,y))
c = numpy.linalg.solve(A, b)
#print numpy.std(numpy.asarray(y)-numpy.sum([c[i]*numpy.asarray(x)**i for i in range(len(c))],axis=0))
xneu = numpy.linspace(100, 250, num=2)
yneu = numpy.sum([c[i]*xneu**i for i in range(len(c))],axis=0)

fig = plt.figure(figsize=(4.2, 3.2))
y1 = plt.plot(x,y,'o')
y2 = plt.plot(xneu,yneu,'r-')
plt.xlabel(u'x (L\u00e4nge in m)')
plt.ylabel(u'y (Breite in m)')
leg = plt.legend(('Messpunkte','Modellfunktion'),frameon=True,loc='lower right')
plt.grid(True, alpha=0.7)
plt.tight_layout()
#plt.savefig('MDKQ2.svg')

Licensing

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.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

1 February 2011

Category:CC-Zero Category:NumPy Category:Numerical analysis Category:Regression analysis Category:Self-published work Category:Valid SVG created with Matplotlib code