Stats.Correlation Method

Definition

Namespace: Numerics.NET.Statistics
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 9.0.0

Overload List

Correlation<T>(ValueTuple<Vector<T>, Vector<T>>) Gets the Pearson correlation coefficient between two sets of values.
Correlation<T>(Vector<T>, Vector<T>) Gets the Pearson correlation coefficient between two sets of values.
Correlation<T>(T[], T[], Boolean) Gets the Pearson correlation coefficient between two arrays.
Correlation<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Boolean) Gets the Pearson correlation coefficient between two arrays.

Correlation<T>(ValueTuple<Vector<T>, Vector<T>>)

Gets the Pearson correlation coefficient between two sets of values.
C#
public static double Correlation<T>(
	this (Vector<T> , Vector<T> ) values
)

Parameters

values  ValueTuple<Vector<T>, Vector<T>>
A tuple of two numerical vectors.

Type Parameters

T
The type of the elements of values.

Return Value

Double
The correlation between the two sets of values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ValueTuple<Vector<T>, Vector<T>>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullException

One of the vectors in values is null.

DimensionMismatchException

The two vectors in values do not have the same length.

Correlation<T>(Vector<T>, Vector<T>)

Gets the Pearson correlation coefficient between two sets of values.
C#
public static double Correlation<T>(
	this Vector<T> values1,
	Vector<T> values2
)

Parameters

values1  Vector<T>
A numerical vector.
values2  Vector<T>
A numerical vector.

Type Parameters

T
The type of the elements of values1 and values2.

Return Value

Double
The correlation between the two sets of values.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Vector<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullException

values1 is null.

-or-

values2 is null.

DimensionMismatchException

The length of values1 does not equal the length of values2.

Correlation<T>(T[], T[], Boolean)

Gets the Pearson correlation coefficient between two arrays.
C#
public static double Correlation<T>(
	this T[] values1,
	T[] values2,
	bool skipMissingValues = false
)

Parameters

values1  T[]
A numerical vector.
values2  T[]
A numerical vector.
skipMissingValues  Boolean  (Optional)
Optional. Specifies whether missing values should be excluded from the calculation. The default is false.

Type Parameters

T
The type of the elements of values1 and values2.

Return Value

Double
The correlation between values1 and values2.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T[]. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

ArgumentNullException

values1 is null.

-or-

values2 is null.

DimensionMismatchException

The length of values1 does not equal the length of values2.

Correlation<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, Boolean)

Gets the Pearson correlation coefficient between two arrays.
C#
public static double Correlation<T>(
	this ReadOnlySpan<T> values1,
	ReadOnlySpan<T> values2,
	bool skipMissingValues
)

Parameters

values1  ReadOnlySpan<T>
A numerical vector.
values2  ReadOnlySpan<T>
A numerical vector.
skipMissingValues  Boolean
Optional. Specifies whether missing values should be excluded from the calculation. The default is false.

Type Parameters

T
The type of the elements of values1 and values2.

Return Value

Double
The correlation between values1 and values2.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type ReadOnlySpan<T>. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Exceptions

DimensionMismatchException

The length of values1 does not equal the length of values2.

See Also