RGetACF ()

Calculates the auto correlation of an array of values.

Synopsis

float RGetACF( const dyn_float vals, float& optLag, int userData = 0);

Parameters

Parameter Description
vals Array of values.
optLag Return parameter for optimal Lag value. The optLag time is returned in seconds.
userData User data of the function call. The user data variable can be set to an integer value and be used to detect errors when calling R functions. Set the variable to an integer value and when the function is called and an error occurs, the specified integer value is returned.

Description

Calculates the auto correlation of an array of values.

Return Value

Correlation result

Example

Calculates the auto correlation of an array and returns the optimal lag value. The lag value specifies the maximum time (delay) between all values of different data points. Several values are often needed to calculate a correlation. The lag value specifies the maximum time that is allowed between all values of different data points. In other words between the two values when two data points are compared.

main()
{
  dyn_float df1 = makeDynFloat(31,31,33,32,34,33,32,35,29,34,38,40,37,38,36,36,36,39,38,40,35,32,34,32,34,29,29,28,31,28,30,34,33,28,31,32,33,33,33,35,36,36,40,38,40,37,40,38,40,38);
  float f;
  float optLag;
  f = RGetACF(df1,optLag);
  DebugTN("Optimal Lag value:", optLag, "Correlation:", f);
}

Assignment

R Functions

Availability

SmartSCADA - R CTRL extension

See also

RGetCCF()