Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Using Kalman Filter To Reduce and Estimate Type A Uncertainties in Sinusoidal Signals

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

METROLOGIA-2003 – Metrologia para a Vida

Sociedade Brasileira de Metrologia (SBM)


Setembro 01−05, 2003, Recife, Pernambuco - BRASIL

USING KALMAN FILTER TO REDUCE AND ESTIMATE TYPE A


UNCERTAINTIES IN SINUSOIDAL SIGNALS

José G. T. Ribeiro 1, Jaime T. P. de Castro 2, José L. F. Freire 3.


1
Secretaria de Ciência e Tecnologia do Exército Brasileiro, Rio de Janeiro, Brasil
2
Pontifícia Universidade Católica, Rio de Janeiro, Brasil
3
Pontifícia Universidade Católica, Rio de Janeiro, Brasil

Abstract: This paper shows the development of a procedure Therefore, an uncertainty component in category A is
to reduce and estimate the Type A uncertainty present in the represented by a statistically estimated standard deviation
measurement of a sinusoidal strain. This procedure is based σ i , equal to the positive square root of the statistically
in a statistical method called Kalman filter. Some
simulations are made, in order to show that this method is estimated variance σ i2 , and the associated number of
really a good choice to improve the accuracy of the degrees of freedom νi . For such a component the standard
measurement since the signal-noise ratio is increased.
uncertainty is ui = σ i . The evaluation of uncertainty by the
Keywords: uncertainty, Kalman filter, strain measurement, statistical analysis of series of observations is termed a Type
simulation, noise reduction. A evaluation (of uncertainty).
A Type A evaluation of standard uncertainty may be
1. INTRODUCTION based on any valid statistical method for treating data.
Examples are calculating the standard deviation of the mean
In general, the result of a measurement is only an of a series of independent observations; using the method of
approximation or estimate of the value of the specific least squares to fit a curve to data in order to estimate the
quantity subject to measurement, that is, the measurand. It parameters of the curve and their standard deviations; and
happens even when the measurement is made carefully. carrying out an analysis of variance (ANOVA) in order to
The uncertainty of the result of a measurement generally identify and quantify random effects in certain kinds of
consists of several components which, in the CIPM measurements [2].
approach, may be grouped into two categories according to The purpose of this paper is to study the application of a
the method used to estimate their numerical values: statistical method called Kalman Filter to evaluate and
ƒ A, those which are evaluated by statistical reduce the Type A uncertainty present in the measurement
methods, of a sinusoidal strain of 25Hz buried in white noise.
ƒ B, those which are evaluated by other means.
In any electronic measurement system, there is noise
present in the measurement. The effect introduced by this 2. THE KALMAN FILTER
noise is to corrupt the signal, affecting its accuracy [1]. In order to reduce the presence of noise, a filtering
This source of error is always present, since it is method must be used. The most popular filtering method is
produced by the instrumentation system itself. For example, the frequency selective filtering. This type of filtering is
electronic amplifiers have a characteristic signal-noise ratio present in many instrumentation systems. This filter can be
that must be the largest possible in order to reduce the noise analog or digital, and there are many types of filter to be
present in the measurement. Another source of noise is the chosen depending on the desired result. The disadvantage of
60Hz power line of the environment. this type of filter is that it does not use any statistical
In general, the noise produced by the electronic devices process, and thus, does not make an optimal filtering.
is not deterministic. This type of noise is called white noise, If a signal is corrupted by noise, it is desirable to make
and must be evaluated using statistical methods. Therefore, the “best” possible separation of them. “Best” in this case
it can be classified as Type A uncertainty. means minimum mean-square error. It leads to a question
Basic to the CIPM approach is representing each that is, what linear operation on an additive combination of
component of uncertainty that contributes to the uncertainty signal and noise will lead to this “best” separation. R.E.
of a measurement result by an estimated standard deviation, Kalman has presented this method of filtering in 1960, when
termed standard uncertainty with suggested symbol ui , and he published his famous paper describing a recursive
equal to the positive square root of the estimated variance solution to the discrete-data linear filtering problem. This
contribution has been especially significant in applied work,
ui2 . because his solution is readily implemented with modern
digital methods.
The Kalman filter is a multiple-input, multiple-output In practice, the process noise covariance Q and
filter that can optimally estimate, in real time, the state of measurement noise covariance R matrices might change
system based on its noisy outputs (Kalman, 1960). These with each time step or measurement, however they are
states are all the variables needed to completely describe the assumed constant.
system behavior as a function of time (such as position, The algorithm of the discrete Kalman filter is described.
velocity, voltage levels, and so forth). In fact, one can think −
The step 1 is to enter a prior estimate for x̂k and for its error
of the multiple noisy outputs as a multidimensional signal

plus noise, with the system states being the desired unknown covariance Pk .
signals. The Kalman filter then filters the noisy Step 2 is to compute a Kalman gain using Eq.(3).
measurements to estimate the desired signals. The estimates
are statistically optimal in the sense that they minimize the
mean-square estimation error. (
K k = Pk− ⋅ H T ⋅ H ⋅ Pk− ⋅ H T + R )
−1
(3)
The Kalman filter is a set of mathematical equations
that provides an efficient computational (recursive) solution Step 3 is to update the estimate using the measurement
of the least-square method. The filter is very powerful in zk, using the Eq.(4).
several aspects; it supports estimations of the past, present,
and even future states, and it can do so even when the
precise nature of the modeled system is unknown. The
(
xˆ k = xˆ k− + K k ⋅ zk − H ⋅ xˆk− ) (4)

Kalman filter tries to estimate the state x ∈ ℜn of a discrete Step 4 is to calculate the error covariance for this
time controlled process (Welch et al., 2001) that is governed updated estimate using the Eq.(5).
by the linear stochastic difference equation
Pk− = A ⋅ Pk −1 ⋅ AT + Q (5)
xk = A ⋅ xk −1 + wk −1 (1)

with a measurement z ∈ ℜn that is Step 5 is to project ahead the values of xˆ k−+1 and Pk +1
using Eq.(6) and Eq.(7). These values will be used as the
z k = H ⋅ x k + vk (2) prior estimate for the next interaction.

where Pk +1 = (I − K k ⋅ H ) ⋅ Pk− (6)

xˆ k−+1 = A ⋅ xˆ k (7)
xk is the (n x 1) process state vector at time tk.
A is the (n x n) state transition matrix that relates xk to
xk+1 in the absence of a forcing function. Then it must back to step 2 described above for the next
wk is the (n x 1) process noise vector that models the interaction. It must be repeated until the end of the
uncertainty of the process. measurement.
zk is the (m x 1) process measurement vector at time tk. During the process the value PK calculated in Eq.(5) is
Hk is the (m x n) measurement matrix that relates state called the error covariance matrix. It is calculated in each
to measurement. interaction and can be used as an estimation of the variance
vk is the (m x 1) measurement noise that models the of the measurement. Therefore its root square can be used as
noise in the measurement. estimation of the uncertainty of the measurement.

The random variables wk e vk are assumed to be 3. APPLYING THE KALMAN FILTER


independent (of each other), and with normal probability
distributions. Suppose a constant strain is being measured and that all
sources of uncertainties have already been identified and the
p( w) ~ N (0, Q) Type B uncertainties have been reduced to very low levels.
Therefore, the remaining uncertainties are all random
p(v) ~ N (0, R) uncertainties. If 10 measurements are made, it can be
obtained the following results in µε.
It means that, in order to use the Kalman Filter, it is
necessary to obtain a model of the process being observed. 10.2 10.0 9.8 10.7 11.0 9.7 10.0 9.5 10.3 8.7
For example, you must know if the process is a constant
value, if it is a sinusoid, if it is a linear process, and so on. If the standard deviation of these measurements is
With this model it is obtained the values of the matrix A calculated, it is obtained the value
and H. The values of Q and R must be obtained using
experimental results. The value of R can be made equal to σ x = 0.7 µε
the single measurement uncertainty of the instrumentation
system used. The value of Q is more difficult to obtain, and
it represents the uncertainty of the model used for the It means that the uncertainty in any single measurement
process. of the strain is 0.7µε. The best estimation of the strain is
obtained calculating the mean value of the measurements, ε = 10.0 ± 0.2µε
and its uncertainty is equal to
σx
σx = (8)
This example showed that the Kalman Filter is a
statistical tool that can be used to estimate the best value of
10
a measurement and its Type A uncertainty.
Thus, after these 10 measurements, it can be obtained the
following value for the strain: 4. FILTERING SINUSOIDAL SIGNALS
The Kalman Filter would not be a useful tool if it could
ε = 10.0 ± 0.2µε be applied only to constant values. If a good model of the
process is obtained, it can be used to improve and estimate
This result can be obtained using the Kalman Filter. the Type A uncertainty of the measurement.
Since the strain being measured is constant, the model of the If the process to be measured is a sinusoidal signal with
strain is shown in the following relations: a known frequency and unknown amplitude and phase, the
model of the process is
ε k = ε k −1 (9)
 cos(2 ⋅ π ⋅ f ⋅ ∆t ) sin(2 ⋅ π ⋅ f ⋅ ∆t ) 
A=  (12)
− sin(2 ⋅ π ⋅ f ⋅ ∆t ) cos(2 ⋅ π ⋅ f ⋅ ∆t )
Then, the corresponding state equation is:

[ε k ] = [1] ⋅ [ε k −1 ]
H = [1 0]
(10)
(13)
and the observation equation is
Figure 1 shows the simulation of the measurement of a
z k = [1] ⋅ [ε k ] + vk
25Hz sinusoidal strain, using a sample rate of 1000 points
(11)
per second with an uncertainty of 0.6µε, therefore R is made
equal to 0.36. Once more it can be said that the value of R
where vk is the measurement noise that is supposed to be can be estimated using the Type A uncertainty of the
white with zero mean and variance R. This value can be measurement system.
made equal to the square of the single measurement The reference signal is shown in full line. It can be
uncertainty calculated above. considered a measurement of this signal using a
The value of Q can be zero, since there is no uncertainty measurement system with an uncertainty much lower than
for the model of the strain measured. That is, it is known the one in the measurement system in study. Therefore, the
that its value is constant. uncertainty of this measurement will be considered
Therefore, the model of first order of the Kalman Filter extremely low and will not be considered.
for this strain measurement is described by the following Suppose it is desired to obtain the peaks of these strain
parameters: in each cycle. It is a common measurement task when it is
making a fatigue test in a specimen.
A = [1]
Q=0
H = [1]

The prior estimates can be the shown in Eq. and Eq.

xˆ k− = 0
Pk− = 0.1

After the application of the Kalman Filter, it is obtained


the following results

xˆ10 = 9.99
P10 = 0.0395 ⇒ P10 = 0.1987
Figure 1: Simulation of the measurement of a sinusoid of 25Hz
using an instrumentation system with a Type A uncertainty of
Therefore, using the Kalman Filter to estimate the best
0.6µε.
value for the strain leads to
Figure 2 shows the 25 peaks obtained in this test. The the measurement, what leads to a standard deviation of
peaks measured range from 10.0±0.6µε to 11.0±0.6µε. 0.1µε.
If the reference signal is used, it is evident that this Type If it is considered the values measured after 0.4 seconds,
A uncertainty introduced a systematic error, since the range the values of peak obtained range from 9.9±0.1µε to
is above the reference value of 10.0. Therefore, the actual 10.1±0.1µε.
uncertainty is not 0.6µε and should be correctly calculated,
but it is not the purpose of this paper.

Figure 3: Result of the application of the Kalman Filter to


Figure 2: Peaks in each cycle of the measurement in Figure 1
measurement of the sinusoidal strain shown in Figure 1.

In order to use the Kalman Filter to reduce and estimate These values are clearly better than the ones obtained
the Type A uncertainty, the model described in Eq.(12) and without the filtering. First of all, the Type A uncertainty has
Eq.(13) must be used with f=25Hz.
been reduced from 0.6µε to 0.1µε.
The value of Q has been determined by trial and error
The second observation is that the systematic error
and it has been used the Eq.(14).
seems to be reduced, since the reference value is in the
middle of the range obtained.
1 0  The third observation is that it must be reminded that
Q= ⋅Γ (14) the amplitude and the phase of the signal were unknown.
0 1  To show once more how powerful the Kalman Filter is,
it will be simulated one more example. Suppose that in the
The value of Γ in Q is assumed to be 0.0001. same measurement, there is a noise of 60Hz induced in the
Experience has shown that to assume a value 0 for Q is not a signal and that this noise introduces a sinusoid with the
good choice, since it is important to permit some uncertainty amplitude of 2µε. Figure 4 shows this measurement.
to the model.

The first value for x̂k has been assumed to be

1 
xˆ0− =  
0

The first value for P0 has been assumed to be

0.1 0.1
P0 =  
0.1 0.1
Figure 3 shows the result of the filtering of the signal
using the Kalman Filter. The filter spent some time to reach
the right value. It happened due to the first estimation for
x̂k− . Figure 4: Simulation of the measurement of a sinusoid of 25Hz
using an instrumentation system with a Type A uncertainty of
The value of Pk establishes in 0.0084 after 200 0.6µε contaminated with a noise of 60Hz and amplitude of 2µε.
interactions. This value can be considered the variance of
 A1,1 A1, 2 0 0 
A A2, 2 0 0 
A=
2 ,1

 0 0 A3,3 A3, 4 
 
 0 0 A4,3 A4, 4 
where

A1,1 = A2, 2 = cos(2 ⋅ π ⋅ 25 ⋅ ∆t )

A1, 2 = − A2,1 = sin (2 ⋅ π ⋅ 25 ⋅ ∆t )

A3,3 = A4, 4 = cos(2 ⋅ π ⋅ 60 ⋅ ∆t )

A3, 4 = − A4,3 = sin (2 ⋅ π ⋅ 60 ⋅ ∆t ) Figure 6: Component of 60Hz present in the signal shown in Figure

H = [1 0 1 0]
4 and estimated using the Kalman Filter.

Figure 5 shows the result of the filtering using this


1 0 0 0 model for the Kalman Filter. It can be verified that the result
0 1 0 0 is equivalent to the result shown in Figure 3. The range
Q= ⋅Γ measurement is between 9.9±0.1µε and 10.1±0.1µε. Figure
0 0 1 0 6 shows the component of 60 Hz that the Kalman Filter
  removed.
0 0 0 1 This example shows that the Kalman Filter is a
statistical method that is able to separate linearly
1  independent signals.
0
xˆ0− =  
1  5. CONCLUSIONS
  The most important conclusion is that the Kalman Filter
0 seems to be a good method to reduce and estimate Type A
0.1 0.1 0.1 0.1 uncertainty present in measurement systems.
0.1 0.1 0.1 0.1
The Kalman Filter is very sensitive to the model used. If
P0 = 
the model is wrong, the results obtained will be diverge
0.1 0.1 0.1 0.1 from the actual value.
  The algorithm of the Kalman Filter can be easily
0.1 0.1 0.1 0.1 implemented in a computer to be used in a on-line
measurement.

REFERENCES
[1] Brindle, I. D. and Zheng, S., “Improvement of Accuracy for
the Determination of Transient Signals Using the Kalman
Filter. Part 1. Simulations”, Analyst, Vol. 117, pp. 1925-
1928, 1992.
[2] Taylor, B.N. and Kuyatt, , “NIST Technical Note 1297 –
Guidelines for Evaluating and Expressing the Uncertainty of
NIST measurements Results”, September, 1994
Autor: D.Sc., José Geraldo Telles Ribeiro, Institute of Research
and Development of Brazilian Army, Av. das Américas , 28.705,
CEP 23.020-470, Rio de Janeiro, R.J., Brazil, jostelles@aol.com.
Ph.D., Jaime Tupiassú Pinho de Castro, Catholic University of Rio
de Janeiro, R. Marquês de São Vicente 225, CEP 22.453-900, Rio
de Janeiro, R.J., Brazil, jtcastro@mec.puc-rio.br.
Figure 5: Result of the application of the Kalman Filter to
measurement of the sinusoidal strain shown in Figure 4. Ph.D., José Luiz França Freire, Catholic University of Rio de
Janeiro, R. Marquês de São Vicente 225, CEP 22.453-900, Rio de
Janeiro, R.J., Brazil, jlfreire@mec.puc-rio.br.

You might also like