Table of Contents

Class StatisticalFunctions

Namespace
SignalSharp.Utilities
Assembly
SignalSharp.dll

Provides a set of statistical functions for numerical data processing.

public static class StatisticalFunctions
Inheritance
StatisticalFunctions
Inherited Members

Methods

Kurtosis<T>(ReadOnlySpan<T>)

Calculates the kurtosis of a set of values.

public static T Kurtosis<T>(ReadOnlySpan<T> values) where T : INumber<T>, IRootFunctions<T>, IPowerFunctions<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The kurtosis of the values.

Type Parameters

T

The numeric type of the values.

Examples

var values = new[] { 1.0, 2.0, 3.0, 4.0, 5.0 };
var kurtosis = StatisticalFunctions.Kurtosis(values);
Console.WriteLine(kurtosis); // Output: -1.3

Remarks

Kurtosis measures the tailedness of the value distribution. The returned value is excess kurtosis, which is kurtosis minus 3. A high kurtosis indicates a distribution with heavy tails and a sharp peak, while a low kurtosis indicates a distribution with light tails and a flat peak.

Exceptions

ArgumentException

Thrown when the number of values is less than 4 or the standard deviation is zero.

Max<T>(ReadOnlySpan<T>)

Calculates the maximum value in a set of values.

public static T Max<T>(ReadOnlySpan<T> values) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The maximum value in the set.

Type Parameters

T

The numeric type of the values.

Exceptions

InvalidOperationException

Thrown when the input sequence is empty.

Mean<T>(ReadOnlySpan<T>)

Calculates the mean (average) of a set of values.

public static T Mean<T>(ReadOnlySpan<T> values) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The mean of the values.

Type Parameters

T

The numeric type of the values.

Examples

var values = new[] { 1.0, 2.0, 3.0 };
var mean = StatisticalFunctions.Mean(values);
Console.WriteLine(mean); // Output: 2.0

Median<T>(ReadOnlySpan<T>, bool)

Calculates the median of a set of values.

public static T Median<T>(ReadOnlySpan<T> values, bool useQuickSelect = false) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

useQuickSelect bool

A flag indicating whether to use the QuickSelect algorithm to compute the median.

Returns

T

The median of the values.

Type Parameters

T

The numeric type of the values.

Examples

var values = new[] { 1.0, 2.0, 3.0, 4.0, 5.0 };
var median = StatisticalFunctions.Median(values);
Console.WriteLine(median); // Output: 3.0

Min<T>(ReadOnlySpan<T>)

Calculates the minimum value in a set of values.

public static T Min<T>(ReadOnlySpan<T> values) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The minimum value in the set.

Type Parameters

T

The numeric type of the values.

Exceptions

InvalidOperationException

Thrown when the input sequence is empty.

Normalize<T>(ReadOnlySpan<T>)

Normalizes a set of values to the range [0, 1].

public static IEnumerable<T> Normalize<T>(ReadOnlySpan<T> values) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

IEnumerable<T>

The normalized values.

Type Parameters

T

The numeric type of the values.

Remarks

Normalization scales the values such that the minimum value becomes 0 and the maximum value becomes 1.

Exceptions

InvalidOperationException

Thrown when the input sequence is empty.

Skewness<T>(ReadOnlySpan<T>)

Calculates the skewness of a set of values.

public static T Skewness<T>(ReadOnlySpan<T> values) where T : INumber<T>, IRootFunctions<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The skewness of the values.

Type Parameters

T

The numeric type of the values.

Examples

var values = new[] { 1.0, 2.0, 2.0, 3.0, 4.0 };
var skewness = StatisticalFunctions.Skewness(values);
Console.WriteLine(skewness); // Output: 0.5657196

Remarks

Skewness measures the asymmetry of the value distribution relative to the mean. A positive skewness indicates a distribution with a tail on the right side, while a negative skewness indicates a distribution with a tail on the left side.

StandardDeviation<T>(ReadOnlySpan<T>)

Calculates the standard deviation of a set of values.

public static T StandardDeviation<T>(ReadOnlySpan<T> values) where T : INumber<T>, IRootFunctions<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The standard deviation of the values.

Type Parameters

T

The numeric type of the values.

Remarks

Standard deviation is the square root of the variance and provides a measure of the spread of values.

Variance<T>(ReadOnlySpan<T>)

Calculates the variance of a set of values.

public static T Variance<T>(ReadOnlySpan<T> values) where T : INumber<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

T

The variance of the values.

Type Parameters

T

The numeric type of the values.

Remarks

Variance measures the dispersion of a set of values from their mean.

ZScoreNormalization<T>(ReadOnlySpan<T>)

Performs Z-score normalization on a set of values.

public static IEnumerable<T> ZScoreNormalization<T>(ReadOnlySpan<T> values) where T : INumber<T>, IRootFunctions<T>

Parameters

values ReadOnlySpan<T>

The set of values.

Returns

IEnumerable<T>

The Z-score normalized values.

Type Parameters

T

The numeric type of the values.

Remarks

Z-score normalization transforms the data such that it has a mean of 0 and a standard deviation of 1.