Correlation

Package: Libraries.Compute.Statistics.Calculations · Inherits from: Libraries.Language.Object

This class calculates the correlation coefficient between two particular DataFrameColumns. The correlation computed from this class is the pearson correlation For more information: https://en.wikipedia.org/wiki/Correlation

Example Code

use Libraries.Compute.Statistics.DataFrame
use Libraries.Compute.Statistics.Calculations.Correlation

//Load a comma separated file
DataFrame frame
frame:Load("Data.csv") 
Correlation correlation

//set the mean before using it. Alternatively, we can allow it to calculate for us.
//The result is received slightly faster if we set it.
correlation:SetMean1(17) 
correlation:SetMean2(12) 
correlation:SetVariance1(3) 
correlation:SetVariance2(2) 
DataFrameColumn column1 = frame:GetColumn(0)
DataFrameColumn column2 = frame:GetColumn(1)
correlation:Calculate(column1, column2)
number corr = correlation:GetCorrelation()

Actions

Calculate(Libraries.Compute.Statistics.DataFrameColumn column1, Libraries.Compute.Statistics.DataFrameColumn column2)

Parameters

Empty()

This calculation can be used again if Empty is called after using it on a column.

GetCorrelation()

Returns the correlation coefficient.

Returns

number

SetMean1(number mean)

Sets the mean1. The correlation then uses this value in its calculation. Saves on computing time if value is already known.

Parameters

  • mean number

SetMean2(number mean)

Sets the mean2. The correlation then uses this value in its calculation. Saves on computing time if value is already known.

Parameters

  • mean number

SetVariance1(number variance)

Sets the var1. The correlation then uses this value in its calculation. Saves on computing time if value is already known.

Parameters

  • variance number

SetVariance2(number variance)

Sets the var2. The correlation then uses this value in its calculation. Saves on computing time if value is already known.

Parameters

  • variance number

Inherited Actions

3 actions from Libraries.Language.Object