File:Kalman Polynom Test.svg
Original file (SVG file, nominally 450 × 315 pixels, file size: 108 KB)
Captions
Summary[edit]
DescriptionKalman Polynom Test.svg |
Deutsch: Der Kalman-Filter wird auf ein Polynom 3. Grades angewendet und versucht aus den verrauschten Daten die Polynomparameter zu schätzen. Im Laufe der Iterationen nährt sich die Schätzung immer mehr an den unverrauschten Verlauf an. |
Date | |
Source | Own work |
Author | Physikinger |
SVG development InfoField | This plot was created with Matplotlib. |
Source code InfoField | Python code# This source code is public domain
# Autor: Christian Schirm
import numpy
import matplotlib.pyplot as plt
# Generate polynomial
nSteps = 301
coeff = [-50, 70, -16, 1]
sigmaNoise = 50
sigmaPrior = 100
xMax = 10
ts = numpy.linspace(0,xMax,nSteps)
deltaT = ts[1] - ts[0]
nPoly = len(coeff)
A = numpy.array([ts**i for i in range(nPoly)])
y_polynomial = coeff @ A
# Noise
numpy.random.seed(1)
noise = sigmaNoise*numpy.random.randn(nSteps)
# Add noise to the signal
y = y_polynomial + noise
# Prepare Kalman estimation
D = numpy.zeros((nPoly,nPoly))
D[(numpy.arange(nPoly-1), numpy.arange(nPoly-1)+1)] = 1
Dt = D*deltaT
F = numpy.identity(nPoly) + Dt + Dt @ Dt/2 + Dt @ Dt @ Dt/6
H = numpy.zeros((1,nPoly))
H[0,0] = 1
# Initialize Kalman estimation
x = numpy.zeros(nPoly)
components = A / nSteps
# P = sigmaPrior**2 * numpy.identity(nPoly)
P = sigmaPrior**2 * numpy.linalg.inv(components @ components.T) # Constant variance prior model
# Start Kalman iteration
yEst = []
ySigma = []
for i in range(len(y)):
# Propagate
if i > 0:
x = F @ x
P = F @ P @ F.T
# Estimate
K = P @ H.T @ numpy.linalg.inv(H @ P @ H.T + sigmaNoise**2)
x = x + K @ (y[i] - H @ x)
P = (numpy.identity(nPoly) - K @ H) @ P
ySigma.append(P[0,0])
yEst.append(x[0])
ySigma = numpy.sqrt(ySigma)
# Plot
plt.figure(figsize=(5,3.5))
plt.plot(ts,y_polynomial,'C3-', label='Polynom 3. Grades', zorder=1)
plt.plot(ts,y,'.-', color='C1', markersize=4, linewidth=0.4, alpha=0.6, label='Polynom + Rauschen', zorder=2)
plt.plot(ts,yEst,'C0-', label='Kalman-Schätzung', zorder=3)
plt.fill_between(ts,y_polynomial-ySigma, y_polynomial+ySigma, color='0.2', alpha=0.17,
label='Fehlerschätzung\n(relativ zu wahrer Kurve)', lw=0, zorder=0)
plt.xlabel('Zeit')
plt.legend(loc=4)
plt.tight_layout()
plt.savefig('Kalman_Polynom_Test.svg')
plt.savefig('Kalman_Polynom_Test.png')
# plt.show()
|
Licensing[edit]
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.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse |
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 20:29, 8 October 2023 | 450 × 315 (108 KB) | Physikinger (talk | contribs) | Legende Reihenfolge, Konfidenz -> Fehlerschätzung | |
09:18, 24 January 2022 | 450 × 315 (111 KB) | Physikinger (talk | contribs) | Typo | ||
16:07, 22 January 2022 | 450 × 315 (104 KB) | Physikinger (talk | contribs) | Korrigiertes a-priori Modell | ||
23:23, 21 January 2022 | 450 × 315 (91 KB) | Physikinger (talk | contribs) | Besseres a-priori Modell und Konfidenzinterval | ||
23:30, 5 May 2021 | 450 × 315 (76 KB) | Physikinger (talk | contribs) | Uploaded own work with UploadWizard |
You cannot overwrite this file.
File usage on Commons
There are no pages that use this file.
File usage on other wikis
The following other wikis use this file:
- Usage on de.wikipedia.org
Metadata
This file contains additional information such as Exif metadata which may have been added by the digital camera, scanner, or software program used to create or digitize it. If the file has been modified from its original state, some details such as the timestamp may not fully reflect those of the original file. The timestamp is only as accurate as the clock in the camera, and it may be completely wrong.
Width | 360pt |
---|---|
Height | 252pt |