Skip to content

Commit 41545f7

Browse files
committed
fixed comments and typos.
Former-commit-id: f4fbf44 [formerly f4fbf44 [formerly b7a5d16]] Former-commit-id: 807561811f21095c4a0684b34a69884e0ccb1c4e Former-commit-id: f9740dd
1 parent 1101540 commit 41545f7

28 files changed

+250
-374
lines changed

matlab/example1_lgss.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% State estimation in a LGSS model using particle and Kalman filters
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25

36
% Set random seed
47
rng(0)
58

6-
% Define the model
9+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10+
% Define the model and generate data
711
% x[t + 1] = phi * x[t] + sigmav * v[t], v[t] ~ N(0, 1)
812
% y[t] = x[t] + sigmae * e[t], e[t] ~ N(0, 1)
13+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914
phi = 0.75;
1015
sigmav = 1.00;
1116
sigmae = 0.10;
1217
parameters = [phi sigmav sigmae];
1318
noObservations = 250;
1419
initialState = 0;
1520

16-
% Generate data
1721
[states, observations] = generateData(parameters, noObservations, initialState);
1822

1923
subplot(3,1,1);
@@ -26,10 +30,14 @@
2630
xlabel('time');
2731
ylabel('latent state');
2832

29-
% State estimation using particle filter with N = 20 particles
33+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
34+
% State estimation
35+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36+
37+
% Particle filter with N = 20 particles
3038
stateEstPF = particleFilter(observations, parameters, 20, initialState);
3139

32-
% State estimation using Kalman filter
40+
% Kalman filter
3341
stateEstKF = kalmanFilter(observations, parameters, initialState, 0.01);
3442

3543
subplot(3,1,3);

matlab/example2_lgss.m

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,39 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Example of particle Metropolis-Hastings in a LGSS model.
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25

36
% Set random seed
47
rng(0)
58

6-
% Define the model
9+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10+
% Define the model and generate data
711
% x[t + 1] = phi * x[t] + sigmav * v[t], v[t] ~ N(0, 1)
812
% y[t] = x[t] + sigmae * e[t], e[t] ~ N(0, 1)
13+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
914
phi = 0.75;
1015
sigmav = 1.00;
1116
sigmae = 0.10;
1217
parameters = [phi sigmav sigmae];
1318
noObservations = 250;
1419
initialState = 0;
1520

16-
% Generate data
1721
[states, observations] = generateData(parameters, noObservations, initialState);
1822

19-
% Setings for PMH
23+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
24+
% PMH
25+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2026
initialPhi = 0.50;
2127
noParticles = 100; % Use noParticles ~ noObservations
2228
noBurnInIterations = 1000;
2329
noIterations = 5000;
2430
stepSize = 0.10;
2531

26-
% Run the PMH algorithm
2732
phiTrace = particleMetropolisHastings(observations, initialPhi, [sigmav sigmae], noParticles, initialState, noIterations, stepSize);
2833

34+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2935
% Plot the results
36+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3037
noBins = floor(sqrt(noIterations - noBurnInIterations));
3138
grid = noBurnInIterations:noIterations;
3239
phiTrace = phiTrace(noBurnInIterations:noIterations);

matlab/example3_sv.m

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,32 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Example of particle Metropolis-Hastings in a stochastic volatility model
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25

36
% Set random seed
47
rng(0)
58

9+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
610
% Load data
11+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
712
data = Quandl.get('NASDAQOMX/OMXS30', 'start_date', '2012-01-02', 'end_date', '2014-01-02', 'type', 'data');
813
logReturns = 100 * diff(log(flipud(data(:, 2))));
914
noObservations = length(logReturns);
1015

11-
% Settings for PMH
16+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17+
% PMH
18+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1219
initialTheta = [0 0.9 0.2];
1320
noParticles = 500; % Use noParticles ~ noObservations
1421
noBurnInIterations = 2500;
1522
noIterations = 7500;
1623
stepSize = diag([0.10 0.01 0.05].^2);
1724

18-
% Run the PMH algorithm
1925
[parameterTrace, logVolatilityEstimate] = particleMetropolisHastingsSVmodel(logReturns, initialTheta, noParticles, noIterations, stepSize);
2026

27+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2128
% Plot the results
29+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2230
grid = noBurnInIterations:noIterations;
2331
noBins = floor(sqrt(noIterations - noBurnInIterations));
2432
logVolatilityEstimate = logVolatilityEstimate(grid, 2:(noObservations + 1));

matlab/generateData.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Generates data from the LGSS model
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function[states, observations] = generateData(parameters, noObservations, initialState)
36
states = zeros(noObservations+1, 1);
47
observations = zeros(noObservations+1, 1);

matlab/kalmanFilter.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
% Kalman filtering for LGSS model
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2+
% Kalman filtering
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function xHatFiltered = kalmanFilter(observations, parameters, initialState, initialStateCov)
36

47
noObservations = length(observations);
@@ -11,9 +14,7 @@
1114
xHatPredicted = initialState * ones( noObservations, 1);
1215
predictiveCovariance = initialStateCov;
1316

14-
% Main loop
1517
for t = 1:noObservations
16-
1718
% Correction step
1819
S = C * predictiveCovariance * C + R;
1920
kalmanGain = predictiveCovariance * C / S;

matlab/particleFilter.m

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Fully-adapted particle filter for the linear Gaussian SSM
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function[xHatFiltered, logLikelihood] = particleFilter(observations, parameters, noParticles, initialState)
36

47
noObservations = length(observations) - 1;
@@ -17,9 +20,7 @@
1720
xHatFiltered(1) = initialState;
1821
particles(:, 1) = initialState;
1922

20-
% Main loop
2123
for t = 2:noObservations
22-
2324
% Resample (multinomial)
2425
newAncestors = randsample(noParticles, noParticles, true, normalisedWeights(:,t - 1));
2526
ancestorIndices(:, 1:(t - 1)) = ancestorIndices(newAncestors, 1:(t - 1));
@@ -48,7 +49,9 @@
4849
end
4950
end
5051

52+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5153
% Helper for computing the logarithm of the Gaussian density
54+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5255
function[out] = dnorm(x, mu, sigma)
5356
out = -0.5 .* log(2 * pi) - 0.5 .* log(sigma.^2) - 0.5 ./ sigma.^2 .* (x - mu).^2;
5457
end

matlab/particleFilterSVmodel.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Bootstrap particle filter for the SV model
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function[xHatFiltered, logLikelihood] = particleFilterSVmodel(observations, parameters, noParticles)
36

47
noObservations = length(observations);
@@ -16,9 +19,7 @@
1619
particles(:, 1) = mu + sigmav / sqrt(1 - phi^2) * normrnd(0, 1, noParticles, 1);
1720
xHatFiltered(1) = mean(particles(:, 1));
1821

19-
% Main loop
20-
for t = 2:(noObservations + 1)
21-
22+
for t = 2:(noObservations + 1)
2223
% Resample (multinomial)
2324
newAncestors = randsample(noParticles, noParticles, true, normalisedWeights(:, t - 1));
2425
ancestorIndices(:, 1:(t - 1)) = ancestorIndices(newAncestors, 1:(t - 1));
@@ -51,7 +52,9 @@
5152
end
5253
end
5354

55+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5456
% Helper for computing the logarithm of N(x; mu, sigma^2)
57+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5558
function[out] = dnorm(x, mu, sigma)
5659
out = -0.5 .* log(2 * pi) - 0.5 .* log(sigma.^2) - 0.5 ./ sigma.^2 .* (x - mu).^2;
5760
end

matlab/particleMetropolisHastings.m

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Particle Metropolis-Hastings (PMH) for the LGSS model
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function[phi] = particleMetropolisHastings(observations, initialPhi, parameters, noParticles, initialState, noIterations, stepSize)
36

47
sigmav = parameters(1);
@@ -15,9 +18,7 @@
1518
parameters = [phi(1) sigmav sigmae];
1619
[~, logLikelihood(1)] = particleFilter(observations, parameters, noParticles, initialState);
1720

18-
% Main loop
19-
for k = 2:noIterations
20-
21+
for k = 2:noIterations
2122
% Propose a new parameter
2223
phiProposed(k) = phi(k-1) + stepSize * normrnd(0, 1);
2324

@@ -27,17 +28,15 @@
2728
[~, logLikelihoodProposed(k)] = particleFilter(observations, thetaProposed, noParticles, initialState);
2829
end
2930

30-
% Compute the acceptance probability
31+
% Compute the acceptance probability (reject if unstable system)
3132
prior = dnorm(phiProposed(k), 0, 1) - dnorm(phi(k - 1), 0, 1);
3233
likelihoodDifference = logLikelihoodProposed(k) - logLikelihood(k - 1);
3334
acceptProbability = exp(prior + likelihoodDifference);
3435
acceptProbability = acceptProbability * (abs(phiProposed(k)) < 1.0);
3536

3637
% Accept / reject step
3738
uniformRandomVariable = unifrnd(0, 1);
38-
3939
if (uniformRandomVariable < acceptProbability)
40-
4140
% Accept the parameter
4241
phi(k) = phiProposed(k);
4342
logLikelihood(k) = logLikelihoodProposed(k);
@@ -62,7 +61,9 @@
6261
end
6362
end
6463

64+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6565
% Helper for computing the logarithm of N(x; mu, sigma^2)
66+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
6667
function[out] = dnorm(x, mu, sigma)
6768
out = -0.5 .* log(2 * pi) - 0.5 .* log(sigma.^2) - 0.5 ./ sigma.^2 .* (x - mu).^2;
6869
end

matlab/particleMetropolisHastingsSVmodel.m

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12
% Particle Metropolis-Hastings (PMH) for the SV model
3+
% (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
function[theta, xHatFiltered] = particleMetropolisHastingsSVmodel(observations, initialParameters, noParticles, noIterations, stepSize)
36
noObservations = length(observations);
47

@@ -14,9 +17,7 @@
1417
theta(1, :) = initialParameters;
1518
[xHatFiltered(1, :), logLikelihood(1)] = particleFilterSVmodel(observations, theta(1, :), noParticles);
1619

17-
% Main loop
18-
for k = 2:noIterations
19-
20+
for k = 2:noIterations
2021
% Propose a new parameter
2122
thetaProposed(k, :) = mvnrnd(theta(k-1, :), stepSize);
2223

@@ -25,23 +26,20 @@
2526
[xHatFilteredProposed(k, :), logLikelihoodProposed(k)] = particleFilterSVmodel(observations, thetaProposed(k, :), noParticles);
2627
end
2728

28-
% Compute the acceptance probability
29+
% Compute the acceptance probability (reject if unstable)
2930
prior = dnorm(thetaProposed(k, 1), 0, 1);
3031
prior = prior - dnorm(theta(k - 1, 1), 0, 1);
3132
prior = prior + dnorm(thetaProposed(k, 2), 0.95, 0.05);
3233
prior = prior - dnorm(theta(k - 1, 2), 0.95, 0.05);
3334
prior = prior + dgamma(thetaProposed(k, 3), 2, 10);
3435
prior = prior - dgamma(theta(k - 1, 3), 2, 10);
35-
3636
likelihoodDifference = logLikelihoodProposed(k) - logLikelihood(k - 1);
3737
acceptProbability = exp(prior + likelihoodDifference);
38-
3938
acceptProbability = acceptProbability * (abs(thetaProposed(k, 2)) < 1.0);
4039
acceptProbability = acceptProbability * (thetaProposed(k, 3) > 0.0);
4140

4241
% Accept / reject step
4342
uniformRandomVariable = unifrnd(0, 1);
44-
4543
if (uniformRandomVariable < acceptProbability)
4644
% Accept the parameter
4745
theta(k, :) = thetaProposed(k, :);
@@ -69,12 +67,16 @@
6967
end
7068
end
7169

70+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7271
% Helper for computing the logarithm of N(x; mu, sigma^2)
72+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7373
function[out] = dnorm(x, mu, sigma)
7474
out = -0.5 .* log(2 * pi) - 0.5 .* log(sigma.^2) - 0.5 ./ sigma.^2 .* (x - mu).^2;
7575
end
7676

77+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7778
% Helper for computing the logarithm of Gamma(x; a, b) with mean a/b
79+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
7880
function[out] = dgamma(x, a, b)
7981
out = a * log(b) - gammaln(a) + (a-1) * log(x) - b * x;
8082
end

python/example1-lgss.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
##############################################################################
12
# State estimation in a LGSS model using particle and Kalman filters
3+
# (c) Johan Dahlin 2017 under MIT license <liu@johandahlin.com.nospam>
4+
##############################################################################
25

36
from __future__ import print_function, division
47
import matplotlib.pylab as plt
@@ -10,19 +13,18 @@
1013
# Set the random seed to replicate results in tutorial
1114
np.random.seed(10)
1215

13-
# Define the model
16+
##############################################################################
17+
# Define the model and generate data
1418
# x[t + 1] = phi * x[t] + sigmav * v[t], v[t] ~ N(0, 1)
1519
# y[t] = x[t] + sigmae * e[t], e[t] ~ N(0, 1)
16-
17-
# Set the parameters of the model theta=(phi, sigmav, sigmae), T, x_0
18-
parameters = np.zeros(3)
20+
##############################################################################
21+
parameters = np.zeros(3) # theta = (phi, sigmav, sigmae)
1922
parameters[0] = 0.75
2023
parameters[1] = 1.00
2124
parameters[2] = 0.10
2225
noObservations = 250
2326
initialState = 0
2427

25-
# Generate data
2628
state, observations = generateData(parameters, noObservations, initialState)
2729

2830
# Plot data
@@ -36,16 +38,19 @@
3638
plt.xlabel("time")
3739
plt.ylabel("latent state")
3840

39-
# State estimation using particle filter with 100 particles
40-
xHatPF, _ = particleFilter(observations, parameters, 100, initialState)
41+
##############################################################################
42+
# State estimation
43+
##############################################################################
44+
45+
# Particle filter with 20 particles
46+
xHatPF, _ = particleFilter(observations, parameters, 20, initialState)
4147

42-
# State estimation using the Kalman filter
48+
# Kalman filter
4349
xHatKF = kalmanFilter(observations, parameters, initialState, 0.01)
4450

4551
# Plot state estimate
4652
plt.subplot(3, 1, 3)
4753
plt.plot(xHatKF[1:noObservations] - xHatPF[0:noObservations-1], color='#7570B3', linewidth=1.5)
4854
plt.xlabel("time")
4955
plt.ylabel("difference in estimate")
50-
5156
plt.show()

0 commit comments

Comments
 (0)