Covariance block

This block calculates a time-weighted moving covariance of two input variables.

Return to Overview of blocks

Covariance block

Description

The output of the block is the moving covariance between two input variables calculated over the last T seconds. The moving covariance is thus calculated over a time window of fixed span (width). The window moves forward as time progresses with the one end anchored to current time.

The covariance, CXY, between two variables, X and Y, is calculated over the time window as follows: CXY = ∑i (Xi - μX) (Yi - μY), where μX is the mean of X and μY is the mean of Y over the window. The larger the absolute value of CXY the higher the covariance. A value of 0 indicates no covariance. 

In essence the covariance function calculates the cross correlation between the variances of two variables over the time window. In the case where the two variables are zero-mean, the cross correlation and covariance functions are identical.

Note that the cross correlation function does not adjust for the averages of the two variables over the time window, i.e. it does not first make them zero-average by subtracting their respective averages before calculating the cross correlation. The covariance function does the latter.

Return to top

Covariance block

Block Type

Statistical block

Input/Output ports

Both input ports can have only fields of type double. The number of outputs is determined by the configuration.

In order for this block to run, both input ports must be connected to sources that only have fields of type double. The window span must also be larger than 0 seconds.

Functions performed on tags

  • On the values - The value is the covariance of the two configured input fields over the window span.

  • On the timestamp - The output time stamp is always set to the execute time.

  • On the quality - The quality is set based on the quality threshold. The quality level is calculated as the number of seconds that both the signals had good quality over the window. This quality level is expressed as a percentage of the window span. If the quality level is less that the quality threshold, the output quality is set to bad, otherwise it is good.

Return to top

Example

  • Sample period = 60s

  • Window span = 300s

  • Quality threshold = 80%

Time Stamps

Process Variable X

Process Variable Y

Covariance

Covariance Quality

02/03/26 12:37 

23 

87 

0.00 

02/03/26 12:38 

12 

34 

320.16 

02/03/26 12:39 

44 

23 

312.40 

02/03/26 12:40 

34 

54 

229.16 

02/03/26 12:41 

26 

71 

156.44 

02/03/26 12:42 

62 

-75.04 

02/03/26 12:43 

17 

29 

-233.20 

02/03/26 12:44 

45 

34 

-217.60 

02/03/26 12:45 

78 

67 

-202.36 

02/03/26 12:46 

18 

83 

12.12 

02/03/26 12:47 

22 

61 

-97.00 

02/03/26 12:48 

70 

49 

44.20 

02/03/26 12:49 

10 

13 

-135.68 

02/03/26 12:50 

21 

26 

162.24 

02/03/26 12:51 

39 

31 

79.92 

 

Example of processing by Covariance block

Return to top


Related topics:

  

CSense 2023- Last updated: June 24,2025