Description
Statistical Signal Processing and Estimation Theory (SIP, EPICO)
1 Random variables
Please see the appendix “Matlab, Octave” of the book.
1.1A few univariate distributions
We consider a zero-mean unit-variance random variable, in the 3 cases below:
- X is normally distributed;
- X is uniformly distributed;
- X is driven by a Gaussian mixture whose both components have the same probability, the same variance; the means are ±m (necessarily, the variance of each component is 1 − m2); we take m = 0.
In all cases, with N = 100 and N = 4000:
- Generate N 1
- Plot the normalized histogram of these N realizationsand plot the probability density function on the same figure.
- Estimate the mean and the standard deviation (mean, std).
- Plot the N realizations as an independent random signal.
1.2 Joint distribution
We consider a zero-mean bivariate normal random variable , where X1 and X2 have variances , and correlation coefficient ρ. Use σ1 = 2, σ2 = 5, ρ = 0,9.
- Generate N = 200 realizations of this random variable.
- Estimate the mean and the variance (mean, cov).
- plot these realizations together with the 91 % confidence ellipses.
2 Kalman filter
A DC motor is driven by the input voltage u(t). The angular position of the rotor θ(t) is measured with an incremental encoder (precision L = 512 angles per lap) which provides the measure y(t) of θ(t). Ω(t) is the angular velocity (Ω(t) = θ˙(t)). To perform a velocity control, we have to estimate online θ(t) and Ω(t), from u(t) and y(t).
2.1 Input voltage
The input voltage u(t) is a zero-mean square wave with period ∆ = 100 ms, and peak-to-peak amplitude A = 0,1 V. This signal is sampled with sample time Ts = 1 ms. Create a MatLab function which provides this sampled input for a duration D: u = inputvoltage(D,A,Delta,Ts), where u is a column vector which contains the sampled input (square).
To generate N realizations of a zero-mean unit-variance random variable:
Gauss : x = randn(N,1);
Uniform : x = 2*sqrt(3)*(rand(N,1)-0.5);
Symmetric Gaussian mixture : m=0.95; x=randn(N,1)*sqrt(1-m*m)+m; k=find(rand(N,1)>0.5); x(k) = x(k)-2*m;
CORO-IMARO AV, CORO-SIP STATES, CORO-EPICO STATES, 2020-2021, Lab work 1/2
2.2 System modeling and simulation
With the state vector, we get the state-space representation:
The input-output signals are sampled with the sample time Ts, The input u(t) is constant between 2 sampling times. Thus, the continuous-time above can be sampled without any approximation using the step invariance method (or zero-order-hold method, “zoh”) 2. For all integer n, and all function f, we note fn = f(nTs).
The measure yn provided by the incremental encoder is a quantization of the actual angular position θn.3
- Write a function [y,x] = simulate(u,G,T,Ts,L,x1), where y is a column matrix (same size as u) which contains the evolution of the output yn, x is a 2-columns matrix which contains the evolution of the state vector; x1 is the initial state vector).
- Test the simulator with G = 50 rad.s−1.V−1 et T = 20 ms.
2.3 Kalman filter
wn is the quantization noise of the incremental encoder, r is its variance (yn = θn+wn). To take into account modeling errors, we assumes that the actual input is un + vn, where vn is a white noise with variance q, independent of wn.
The goal is to estimate Xn. The motor is initially stopped, but there is no information on the initial angular position.
- Write the equations of the Markov model of the system with input un and output yn.
- Propose a value of r (it is usual to model a quantization error as a uniform random variable).
- Propose an initialization of the prior information Xˆ1/0 and propose a value for its variance P1/0.
- Write the Kalman filter4 and the stationary Kalman filter5, that is two functions xe = kal(y, u, G, T, Ts, L, x1 0, P1 0, q), where xe is a 2-columns matrix which contains the evolution of the state vector estimation.
2.4 Simulations
Compare the estimation of the position and the velocity given by both filters for different values of q (use the initialization θˆ1/0 = θ1 ± 0.05) in the following cases:
- the model of the system is perfect: Gactual = Gfilter = 50 rad.s−1.V−1 Tactual = Tfilter = 20 ms −1 −1
Gactual = Gfilter = 50 rad.s .V • the model of the system is rough: Tactual = 20 ms
Tfilter = 25 ms
“actual” index if for the value used in the simulation, “filter” index is for the value used in the Kalman filter.
2
For a continuous-time system with the state space representation:
the step invariance sampling with sample time Ts writes (see MatLab function c2dm):
with
3
With L angles per lap, the precision is 2π/L rad. With MatLab: y = round(teta*L/2/pi)*2*pi/L
4
With time-varying Kalman gain, page 47 of the book.
5
With constant gain obtained with function dlqe, page 48 of the book.


