Skip to content

API Docs - v4.0.8

Kf

kalmanFilter (Function)

This extension provides Kalman filtering capabilities to Siddhi. This allows you to detect outliers of input data. This function uses measurements observed over time containing noise and other inaccuracies, and produces estimated values for the current measurement using the Kalman algorithm.

Syntax

<DOUBLE> kf:kalmanFilter(<DOUBLE> measured.value, <DOUBLE> measured.changing.rate, <DOUBLE> measurement.noise.sd, <LONG> timestamp)

QUERY PARAMETERS

Name Description Default Value Possible Data Types Optional Dynamic
measured.value The sequential change in the observed measurement. DOUBLE No No
measured.changing.rate The rate at which the measured change is taking place. DOUBLE No No
measurement.noise.sd The standard deviation of the noise. DOUBLE No No
timestamp The time stamp of the time at which the measurement was carried out. LONG No No

Examples EXAMPLE 1

from cleanedStream 
select kf:kalmanFilter(latitude) as kalmanEstimatedValue 
insert into dataOut;

This function produces estimated values for the current measurement using the Kalman algorithm. In order to do this, it is assumed that the current measurement is a static value. The lattitude is a double value indicated by the measuredValue. e.g., 40.695881
Ex:    

    1st round: kf:kalmanFilter(-74.178444) returns an estimated value of -74.178444.
    2nd round: kf:kalmanFilter(-74.175703) returns an estimated value of -74.1770735006853.
    3rd round: kf:kalmanFilter(-74.177872) returns an estimated value of -74.1773396670348.

EXAMPLE 2

from cleanedStream 
select kf:kalmanFilter(latitude, noisesd) as kalmanEstimatedValue 
insert into dataOut;

This function produces estimated values for the current measurement using the Kalman algorithm. In order to do this, it is assumed that the current measurement is a static value, and the distributed standard deviation is considered as the standard deviation of noise. The standard deviation of noise is a double value as indicated by the measurementNoiseSD parameter. e.g., 0.01
Ex:     

    1st round: kf:kalmanFilter(-74.178444, 0.003) returns an estimated value of -74.178444.
    2nd round: kf:kalmanFilter(-74.175703, 0.003) returns an estimated value of -74.17707350205573.
    3rd round: kf:kalmanFilter(-74.177872, 0.003) returns an estimated value of -74.177339667771.

EXAMPLE 3

from cleanedStream 
select kf:kalmanFilter(latitude, measuredchangingrate, noisesd, timestamp) as kalmanEstimatedValue 
insert into dataOut;

This function produces estimated values for the current measurement using the Kalman algorithm. In order to do this, it is assumed that the current measurement is a dynamic value that can be changed with the given value. The timestamp is a long value and it indicates the time at which the measurement is carried out.
Ex:    

    1st round: kf:kalmanFilter(-74.178444, 0.003, 0.01, time:timestampInMilliseconds() ) returns an estimated value of -74.1784439700006.
    2nd round: kf:kalmanFilter(-74.178444, 0.003, 0.01, time:timestampInMilliseconds() ) returns an estimated value of -74.1784439700006.
    3rd round: kf:kalmanFilter(-74.177872, 0.003, 0.01, time:timestampInMilliseconds()) returns an estimated value of -74.17697314316393.