Libraries.Compute.Statistics.Calculations.Correlation Documentation

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()

Inherits from: Libraries.Language.Object

Actions Documentation

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

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Empty()

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

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

GetCorrelation()

Returns the correlation coefficient.

Return

number:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

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

  • number mean

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

  • number mean

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

  • number variance

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

  • number variance