blockCorrelation

Calculates the correlation of two signals
Diagram of Correlation

Extends from Modelica.Blocks.Interfaces.SI2SO (2 Single Input / 1 Single Output continuous control block).

Information

This block calculates the correlation coefficient r between its two input signals. It should be r=1, if you use the same signal on both inputs. You can however also set the time delay delta_t, in order to perform an auto-correlation of the same signal.

Both properties are important for random numbers, as these numbers should be uncorrelated

  1. for different seeds and
  2. for time delays greater than the sample time.

Parameters

TypeNameDefaultDescription
Modelica.Units.SI.Timedelta_t0.0Time delay for auto-correlation of signal

Connectors

TypeNameDefaultDescription
RealInputu1 (from SI2SO)Connector of Real input signal 1
RealInputu2 (from SI2SO)Connector of Real input signal 2
RealOutputy (from SI2SO)Connector of Real output signal

Components

TypeNameDefaultDescription
Modelica.Units.SI.Timetmax(0, time - delta_t - t_0)The local integration time (starts only after an offset of delta_t
RealXu1The first random variable to calculate the correlation coefficient
RealYdelay(u2, delta_t, delta_t + 0.1)The second random variable to calculate the correlation coefficient
Realint_XThe integral of X
Realint_YThe integral of Y
Realint_X2The integral of X^2
Realint_Y2The integral of Y^2
Realint_XYThe integral of X*Y
Realmean_Xif t <= 0 then X else int_X/tThe mean value of X
Realmean_Yif t <= 0 then Y else int_Y/tThe mean value of Y
Realvar_Xif t <= 0 then 0 else (int_X2 - 2*mean_X*int_X + mean_X^2*t)/tThe variance of X
Realvar_Yif t <= 0 then 0 else (int_Y2 - 2*mean_Y*int_Y + mean_Y^2*t)/tThe variance of Y
Realcov_XYif t <= 0 then 0 else (int_XY - mean_X*int_Y - mean_Y*int_X + mean_X*mean_Y*t)/tThe co-variance of X and Y
RealrnoEvent(if var_X <= 0 then 1.0 else if var_Y <= 0 then 1.0 else if var_X*var_Y <= cov_XY^2 then 1.0 else cov_XY/sqrt(abs(var_X))/sqrt(abs(var_Y)))The Bravais- or Pearson-Correlation-Coefficient r = cov_XY / std_X / std_Y

Revisions

DLR logo Developed 2014 at the DLR Institute of System Dynamics and Control