0% found this document useful (0 votes)
63 views10 pages

University of Oulu

The document is about implementing a Kalman filter in MATLAB to estimate channel parameters from noisy observations. It contains: 1) An overview of Kalman filtering theory and equations for a vector state and scalar observation model. 2) Details of implementing the Kalman filter recursively in MATLAB for different parameter settings. 3) Results showing the estimated channel tap weights converging to the true values over time for different scenarios.

Uploaded by

diluna adeesha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views10 pages

University of Oulu

The document is about implementing a Kalman filter in MATLAB to estimate channel parameters from noisy observations. It contains: 1) An overview of Kalman filtering theory and equations for a vector state and scalar observation model. 2) Details of implementing the Kalman filter recursively in MATLAB for different parameter settings. 3) Results showing the estimated channel tap weights converging to the true values over time for different scenarios.

Uploaded by

diluna adeesha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

UNIVERSITY OF OULU

Faculty of Information and Electrical Engineering


Statistical signal processing 2
521324S

MATLAB exercise 2

GROUP MEMBERS :

A.L.A.V.Isuru 2655220
D.K.M.A.M.Padmal 2655246

SUPERVISOR :

Kien-Giang Nguyen

January 27, 2020


1 Theory
Kalman filter is a recursive filtering algorithm which can be used to estimate optimally, the sta-
tionary or non stationary variables of interest when variables can’t be measured directly, but an
indirect measurement is available.Kalman filter is commonly used in various application such as
channel estimation, radar navigation, vehicular tracking and etc.
To estimate the actual parameters form noisy observation, Kalman filter requires two types of
model.
1. State transition model
s[n] = As[n − 1] + Bu[n] (1)

Here u[n] ∼ N (0, Cu ) and s[n] is state and A is transition matrix.


2. Observation model
x[n] = Hs[n] + w[n] (2)

Here u[n] ∼ N (0, Cw ) and x[n] is the noisy observation.


A,B,H can be either matrices or vector or scalar.Therefore Kalman filter can be categorized into
three types.
1. Scalar State and Scalar Observation
2. Vector State and Scalar Observation
3. Vector State and Vector Observation
Through our simulation,We will discuss about kalman filter with the type of Vector state and scalar
observation type.
Derivation of Kalman filter
In our simulation , Equation 1 and Equation 2 become following expressions.

h[n] = Ah[n − 1] + u[n] (3)

Here h[n] is a vector with number of elements ’p’ of channel state and u[n] ∼ N (0, Q)

x[n] = vT h[n] + w[n] (4)


Here x[n] is a scalar observation, v is known discrete time information signal with size p and
w[n] ∼ N (0, σ 2 ).
From Equation 3, We can define the prediction state of channel as follows.

ĥ[n|n − 1] = E[h[n]|x[n − 1], x[n − 2], ..., x[0]]

ĥ[n|n − 1] = E[Ah[n − 1] + u[n]|x[n − 1], x[n − 2], ..., x[0]]


Since u[n] is independent from the observation(x) and mean is zero , above equation can be
simplified up to following equation.

ĥ[n|n − 1] = E[Ah[n − 1]|x[n − 1], x[n − 2], ..., x[0]]

ĥ[n|n − 1] = AE[h[n − 1]|x[n − 1], x[n − 2], ..., x[0]]


ĥ[n|n − 1] = Aĥ[n − 1|n − 1] (5)
Then, Mean square error for the channel estimation can be expressed using following equation,

M[n|n − 1] = E[(h[n] − ĥ[n|n − 1])(h[n] − ĥ[n|n − 1])T ]

1
Using Equation 3 and 5, above expression can be simplified as follows.

M[n|n − 1] = E[(Ah[n − 1] + u[n] − Aĥ[n − 1|n − 1])(Ah[n − 1] + u[n] − Aĥ[n − 1|n − 1])T ]

As the reasons of independence between u[n] and h[n] expected value of cross terms will be vanished
and expression will be expressed as below.

M[n|n − 1] = AE[((h[n − 1] − ĥ[n − 1|n − 1])(h[n − 1] − ĥ[n − 1|n − 1])T ]AT + E[u[n]uT [n]]

but M[n−1|n−1] = E[((h[n−1]− ĥ[n−1|n−1])(h[n−1]− ĥ[n−1|n−1])T ] and Q = E[u[n]uT [n]],


therefore MSE become
M[n|n − 1] = AM[n − 1|n − 1]AT + Q (6)
Define innovation term of the new data sample as x̃[n] = x[n] − x̂[n|n − 1].

x̂[n|n − 1] = E[x[n]|x[n − 1], ..., x[0]]


From Equation 2,
x̂[n|n − 1] = E[vT h[n] + w[n]|x[n − 1], ..., x[0]]
Due to independence of w[n] and x terms,

x̂[n|n − 1] = E[vT h[n]|x[n − 1], ..., x[0]]

x̂[n|n − 1] = vT E[h[n]|x[n − 1], ..., x[0]]


x̂[n|n − 1] = vT ĥ[n|n − 1]

Then we can define the new estimation for the channel coefficient as follows

ĥ[n|n] = ĥ[n|n − 1] + K[n]x̃[n]

ĥ[n|n] = ĥ[n|n − 1] + K[n](x[n] − vT ĥ[n|n − 1]) (7)


Here K[n] is the Kalman gain and it can be found using following method.

K[n] = arg min(M[n|n])

K[n] = arg minE[(h[n] − ĥ[n|n])(h[n] − ĥ[n|n])T ]


∂M[n|n]
Using Equation 3 and 7 with ∂K = 0 , We can determine the Kalaman gain with below
equation.
M[n|n − 1]v
K[n] = (8)
σ2 + vT M[n|n − 1]v
As well as , MSE for the new state can be found using following steps.

M[n|n] = E[(h[n] − ĥ[n|n])(h[n] − ĥ[n|n])T ]

Using Equation 7 We can simplified the above equation up to following expression.

M[n|n] = (I − K[n]vT )M[n|n − 1] (9)

Equation 5 , 6, 8, 7 and 9 represent the recursive Kalman filter algorithm. Using initial state
ĥ[−1| − 1] = µh and M[−1| − 1] = C, We can find the each and every state of the variable of
interest with considerable accuracy for the given time.

2
Kalman Filter Equations

ĥ[n|n − 1] = Aĥ[n − 1|n − 1]

M[n|n − 1] = AM[n − 1|n − 1]AT + Q


M[n|n − 1]v
K[n] =
σ2 + vT M[n|n − 1]v
ĥ[n|n] = ĥ[n|n − 1] + K[n](x[n] − vT ĥ[n|n − 1])
M[n|n] = (I − K[n]vT )M[n|n − 1]

2 Implementation
Task 1
To perform the first task in the simulation, Equation 5 , 6, 8, 7 and 9 are implemented as recursive
algorithm in MATLAB with help of initial state. ĥ[−1| − 1] = µh = 0 and M[−1| − 1] = C = 100I
and the following parameters.
   
0.99 0 0.0001 0
p = 2 (size of the state vector) A = , λ1 = 0.99, λ2 = 0.999, Q =
0 0.999 0 0.0001
and σ 2 = 0.1, λ1 , λ2 are eigen values of matrix A.
Results are shown in Figures 1, 2 ,3 ,4 and 5

Task 2
Change the following parameter in MATLAB program used in Task 1.
 
0.9 0
A= λ = 0.9 λ2 = 0.99
0 0.99 1
Results are Shown in Figures 6, 7 ,8, 9 and 10

Task 3
Change the following parameter in MATLAB program used in Task 1.
   
0.99 0 0.01 0
A= , λ1 = 0.99, λ2 = 0.999 and Q =
0 0.999 0 0.01
Results are Shown in Figures 11, 12, 13, 14, 15

Task 4
Change the following parameter in MATLAB program used in Task 1.
   
0.99 0.01 0.001 0
A= , λ1 = 1.00547, λ2 = 0.983534 and Q =
0.01 0.999 0 0.001
Results are Shown in Figures 16, 17, 18 ,19 and 20

3
3 Simulation results and Discussion
Task 1

1.5
tap weight,hn[0]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

1.5
tap weight,hn[1]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 1: Realization of TDL coefficients


True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]

3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
True and estimated tap weight,hn[1]]

Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]

3
2 0.5
1
0 0

-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 2: Input - output wave forms of channel Figure 3: Kalman filter estimations

4
1 0.2

Minimum MSE, M11[n]


Kalman gain, K1[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

1 0.2

Minimum MSE, M22[n]


Kalman gain, K2[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

Figure 4: Kalman filter gains Figure 5: Kalman filter minimum MSE

Above Figures are quite similar to the figures given in Example 13.3 in Text Book[1]

Task 2

1.5
tap weight,hn[0]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

1.5
tap weight,hn[1]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 6: Realization of TDL coefficients

5
True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1

True and estimated tap weight,hn[1]]


Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]

3
2 0.5
1
0 0

-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 7: Input - output wave forms of channel Figure 8: Kalman filter estimations

1 0.2

Minimum MSE, M11[n]


Kalman gain, K1[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

1 0.2
Minimum MSE, M22[n]
Kalman gain, K2[n]]

0.15

0.5 0.1

0.05

0
0
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

Figure 9: Kalman filter gains Figure 10: Kalman filter minimum MSE

When changing parameters as given in the task 2 , Kalman gain is converge to the zero quickly
and form low amount of oscillations around zero (Figure 9) compared to the task 1(Figure 4).
Therefore MSE value is converged to the zero value with low amount of samples compared to the
task 1.This mean estimation will not depend on the new samples and it follows the true value
under low amount of the samples(Figure 8).
This is due to the channel tap coefficients are propagation onto zero limit with minimum number
of samples(Figure 6) along with changing of transition matrix(A). As well as matrix A has low
eigenvalues in this case compared to the task 1.

6
Task 3

1.5
tap weight,hn[0]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

1.5
tap weight,hn[1]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 11: Realization of TDL coefficients


True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]

3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1
True and estimated tap weight,hn[1]]

Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]

3
2 0.5
1
0 0

-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 12: Input - output wave forms of channel Figure 13: Kalman filter estimations

7
1 0.2

Minimum MSE, M11[n]


Kalman gain, K1[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

1 0.2

Minimum MSE, M22[n]


Kalman gain, K2[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

Figure 14: Kalman filter gains Figure 15: Kalman filter minimum MSE

According to the Figure 11, channel tap coefficient (specially h[0]) converge into the zero with rapid
fluctuations compared to the above tasks.this is because co variance matrix Q has higher value as
its elements under this task.
Also Kalman gain has rapid oscillations around the zero compared to the above tasks(Figure
14).Therefore our prediction estimation model gets more samples to follow the true state(Figure
13).Also MSE value is fluctuating highly instead of converging to the zero.

Task 4

1.5
tap weight,hn[0]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

1.5
tap weight,hn[1]]

0.5

-0.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 16: Realization of TDL coefficients

8
True and estimated tap weight,hn[0]]
noiseless channel output, y[n]channel input,v[n]
3 1.5
2
1 1
0
0.5
-1
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 0
3
2 -0.5
0 10 20 30 40 50 60 70 80 90 100
1

True and estimated tap weight,hn[1]]


Sample number, n
0
-1 1.5
0 10 20 30 40 50 60 70 80 90 100
Sample number, n 1
channel output, x[n]

3
2 0.5
1
0 0

-1
0 10 20 30 40 50 60 70 80 90 100 -0.5
Sample number, n 0 10 20 30 40 50 60 70 80 90 100
Sample number, n

Figure 17: Input - output wave forms of channel Figure 18: Kalman filter estimations

1 0.2

Minimum MSE, M11[n]


Kalman gain, K1[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

1 0.2
Minimum MSE, M22[n]
Kalman gain, K2[n]]

0.15
0.5
0.1

0
0.05

0
-0.5
0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 100
Sample number, n Sample number, n

Figure 19: Kalman filter gains Figure 20: Kalman filter minimum MSE

Channel coefficient are increasing compared to the other tasks(Figure 16).But still Kalman gain
converge to the zero with lower oscillations compared to the task 3(Figure 19). In addition MSE
is converged to the zero with reasonable number of samples(Figure 20).Also our prediction model
behave with the true value at considerable accuracy and low fluctuations(Figure 18).This is because
co variance matrix Q has lower values in its diagonal, and provide little fluctuation to our state
model given in Equation 3.

References
[1] Steven M. Kay. Fundamentals of Statistical Signal Processing: Estimation . PRENTICE HALL
SIGNAL PROCESSING SERIES, volume 1.
[2] MATLAB help, https://se.mathworks.com/help/matlab/

4 Matlab Codes
MATLAB program purpose
Lab2 KalmanFilter Implement the Kalman filter to filter out the desired state from the
noisy observation using recursive algorithm

Table 1: MATLAB program

You might also like