Class Measures
Set of statistics measures, such as Mean(Double[]), Variance(Double[]) and StandardDeviation(Double[], Boolean).
Inheritance
Namespace: ISynergy.Framework.Mathematics.Statistics
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public static class Measures : object
Methods
View SourceContraHarmonicMean(Double[])
Computes the contraharmonic mean of the given values.
Declaration
public static double ContraHarmonicMean(double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A unsigned short array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The contraharmonic mean of the given data. |
ContraHarmonicMean(Double[], Int32)
Computes the contraharmonic mean of the given values.
Declaration
public static double ContraHarmonicMean(double[] values, int order)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A unsigned short array containing the vector members. |
System.Int32 | order | The order of the harmonic mean. Default is 1. |
Returns
Type | Description |
---|---|
System.Double | The contraharmonic mean of the given data. |
Correlation(Double[][])
Calculates the correlation matrix for a matrix of samples.
Declaration
public static double[][] Correlation(this double[][] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A multi-dimensional array containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double[][] | The correlation matrix. |
Remarks
In statistics and probability theory, the correlation matrix is the same as the covariance matrix of the standardized random variables.
Correlation(Double[][], Double[], Double[])
Calculates the correlation matrix for a matrix of samples.
Declaration
public static double[][] Correlation(this double[][] matrix, double[] means, double[] standardDeviations)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double[] | standardDeviations | The values' standard deviation vector, if already known. |
Returns
Type | Description |
---|---|
System.Double[][] | The correlation matrix. |
Remarks
In statistics and probability theory, the correlation matrix is the same as the covariance matrix of the standardized random variables.
Correlation(Double[,])
Calculates the correlation matrix for a matrix of samples.
Declaration
public static double[, ] Correlation(this double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A multi-dimensional array containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double[,] | The correlation matrix. |
Remarks
In statistics and probability theory, the correlation matrix is the same as the covariance matrix of the standardized random variables.
Correlation(Double[,], Double[], Double[])
Calculates the correlation matrix for a matrix of samples.
Declaration
public static double[, ] Correlation(this double[, ] matrix, double[] means, double[] standardDeviations)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double[] | standardDeviations | The values' standard deviation vector, if already known. |
Returns
Type | Description |
---|---|
System.Double[,] | The correlation matrix. |
Remarks
In statistics and probability theory, the correlation matrix is the same as the covariance matrix of the standardized random variables.
Covariance(Double[], Double, Double[], Double, Boolean)
Computes the Covariance between two arrays of values.
Declaration
public static double Covariance(this double[] vector1, double mean1, double[] vector2, double mean2, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | vector1 | A number array containing the first vector elements. |
System.Double | mean1 | The mean value of |
System.Double[] | vector2 | A number array containing the second vector elements. |
System.Double | mean2 | The mean value of |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Covariance(Double[], Double[], Boolean)
Computes the Covariance between two arrays of values.
Declaration
public static double Covariance(this double[] vector1, double[] vector2, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | vector1 | A number array containing the first vector elements. |
System.Double[] | vector2 | A number array containing the second vector elements. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Covariance(Double[][])
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[][] Covariance(this double[][] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Covariance(Double[][], Double[])
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[][] Covariance(this double[][] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Covariance(Double[][], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[][] Covariance(this double[][] matrix, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Int32 | dimension | The dimension of the matrix to consider as observations. Pass 0 if the matrix has observations as rows and variables as columns, pass 1 otherwise. Default is 0. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Covariance(Double[,])
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] Covariance(this double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Covariance(Double[,], Double[])
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] Covariance(this double[, ] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Covariance(Double[,], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] Covariance(this double[, ] matrix, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Int32 | dimension | The dimension of the matrix to consider as observations. Pass 0 if the matrix has observations as rows and variables as columns, pass 1 otherwise. Default is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
In statistics and probability theory, the covariance matrix is a matrix of covariances between elements of a vector. It is the natural generalization to higher dimensions of the concept of the variance of a scalar-valued random variable.
Entropy(IList<Int32>, Int32)
Computes the entropy for the given values.
Declaration
public static double Entropy(IList<int> values, int classes)
Parameters
Type | Name | Description |
---|---|---|
IList<System.Int32> | values | An array of integer symbols. |
System.Int32 | classes | The number of distinct classes. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
Entropy(IList<Int32>, Int32, Int32)
Computes the entropy for the given values.
Declaration
public static double Entropy(IList<int> values, int startValue, int endValue)
Parameters
Type | Name | Description |
---|---|---|
IList<System.Int32> | values | An array of integer symbols. |
System.Int32 | startValue | The starting symbol. |
System.Int32 | endValue | The ending symbol. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
Entropy(Boolean, Boolean)
Computes the entropy function between an expected value and a predicted value.
Declaration
public static double Entropy(bool expected, bool predicted)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | expected | |
System.Boolean | predicted |
Returns
Type | Description |
---|---|
System.Double |
Entropy(Boolean, Double)
Computes the entropy function between an expected value and a predicted value between 0 and 1.
Declaration
public static double Entropy(bool expected, double predicted)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | expected | |
System.Double | predicted |
Returns
Type | Description |
---|---|
System.Double |
Entropy(Double[])
Computes the entropy for the given values.
Declaration
public static double Entropy(this double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
Returns
Type | Description |
---|---|
System.Double | The calculated entropy for the given values. |
Entropy(Double[], Func<Double, Double>)
Computes the entropy function for a set of numerical values in a given Probability Density Function (pdf).
Declaration
public static double Entropy(this double[] values, Func<double, double> pdf)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
Func<System.Double, System.Double> | A probability distribution function. |
Returns
Type | Description |
---|---|
System.Double | The distribution's entropy for the given values. |
Entropy(Double[], NumericRange)
Computes the entropy for the given values.
Declaration
public static double Entropy(double[] values, NumericRange valueRange)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An array of integer symbols. |
NumericRange | valueRange | The range of symbols. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
Entropy(Double[], Double)
Computes the entropy for the given values.
Declaration
public static double Entropy(this double[] values, double eps = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double | eps | A small constant to avoid |
Returns
Type | Description |
---|---|
System.Double | The calculated entropy for the given values. |
Entropy(Double[], Double, Double)
Computes the entropy for the given values.
Declaration
public static double Entropy(double[] values, double startValue, double endValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An array of integer symbols. |
System.Double | startValue | The starting symbol. |
System.Double | endValue | The ending symbol. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
Entropy(Double[], Double[], Func<Double, Double>)
Computes the entropy function for a set of numerical values in a given Probability Density Function (pdf).
Declaration
public static double Entropy(this double[] values, double[] weights, Func<double, double> pdf)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double[] | weights | The importance for each sample. |
Func<System.Double, System.Double> | A probability distribution function. |
Returns
Type | Description |
---|---|
System.Double | The distribution's entropy for the given values. |
Entropy(Double[,])
Computes the entropy for the given values.
Declaration
public static double Entropy(this double[, ] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | values | A number matrix containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double | The calculated entropy for the given values. |
Entropy(Double[,], Double)
Computes the entropy for the given values.
Declaration
public static double Entropy(this double[, ] values, double eps = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | values | A number matrix containing the matrix values. |
System.Double | eps | A small constant to avoid |
Returns
Type | Description |
---|---|
System.Double | The calculated entropy for the given values. |
Entropy(Int32[], Int32)
Computes the entropy for the given values.
Declaration
public static double Entropy(int[] values, int classes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An array of integer symbols. |
System.Int32 | classes | The number of distinct classes. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
ExponentialWeightedCovariance(Double[][], Double, Boolean)
Calculates the exponentially weighted covariance matrix.
Declaration
public static double[, ] ExponentialWeightedCovariance(this double[][] matrix, double alpha = null, bool unbiased = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix of observations whose EW covariance matrix will be calculated. It is assumed that the matrix is ordered with the most recent observations at the bottom of the matrix. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
System.Boolean | unbiased | Use a standard estimation bias correction. |
Returns
Type | Description |
---|---|
System.Double[,] | Returns a vector containing the exponentially weighted average of the columns of the given matrix. |
Examples
The following example shows how to compute the EW covariance matrix.
View SourceExponentialWeightedCovariance(Double[][], Int32, Double, Boolean)
Calculates the exponentially weighted covariance matrix.
Declaration
public static double[, ] ExponentialWeightedCovariance(this double[][] matrix, int window, double alpha = null, bool unbiased = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix of observations whose EW covariance matrix will be calculated. It is assumed that the matrix is ordered with the most recent observations at the bottom of the matrix. |
System.Int32 | window | The number of rows to be used in the calculation. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
System.Boolean | unbiased | Use a standard estimation bias correction. |
Returns
Type | Description |
---|---|
System.Double[,] | Returns a vector containing the exponentially weighted average of the columns of the given matrix. |
Examples
The following example shows how to compute the EW covariance matrix.
View SourceExponentialWeightedMean(Double[], Double)
Calculates the exponentially weighted mean.
Declaration
public static double ExponentialWeightedMean(this double[] values, double alpha = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A vector of observations whose EW mean will be calculated. It is assumed that the vector is ordered with the most recent observations at the end of the vector (and the oldest observations at the start). |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
Returns
Type | Description |
---|---|
System.Double | Returns a |
Examples
The following example shows how to compute the EW mean.
View SourceExponentialWeightedMean(Double[], Int32, Double)
Calculates the exponentially weighted mean.
Declaration
public static double ExponentialWeightedMean(this double[] values, int window, double alpha = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A vector of observations whose EW mean will be calculated. It is assumed that the vector is ordered with the most recent observations at the end of the vector (and the oldest observations at the start). |
System.Int32 | window | The number of samples to be used in the calculation. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
Returns
Type | Description |
---|---|
System.Double | Returns a |
Examples
The following example shows how to compute the EW mean.
View SourceExponentialWeightedMean(Double[][], Double)
Calculates the exponentially weighted mean vector.
Declaration
public static double[] ExponentialWeightedMean(this double[][] matrix, double alpha = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix of observations whose EW mean vector will be calculated. It is assumed that the matrix is ordered with the most recent observations at the bottom of the matrix. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the exponentially weighted average of the columns of the given matrix. |
Examples
The following example shows how to compute the EW mean.
View SourceExponentialWeightedMean(Double[][], Int32, Double)
Calculates the exponentially weighted mean vector.
Declaration
public static double[] ExponentialWeightedMean(this double[][] matrix, int window, double alpha = null)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix of observations whose EW mean vector will be calculated. It is assumed that the matrix is ordered with the most recent observations at the bottom of the matrix. |
System.Int32 | window | The number of rows to be used in the calculation. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the exponentially weighted average of the columns of the given matrix. |
Examples
The following example shows how to compute the EW mean.
View SourceExponentialWeightedVariance(Double[], Double, Boolean)
Calculates the exponentially weighted variance.
Declaration
public static double ExponentialWeightedVariance(this double[] values, double alpha = null, bool unbiased = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A vector of observations whose EW variance will be calculated. It is assumed that the vector is ordered with the most recent observations at the end of the vector (and the oldest observations at the start). |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
System.Boolean | unbiased | Use a standard estimation bias correction. |
Returns
Type | Description |
---|---|
System.Double | Returns a |
Examples
The following example shows how to compute the EW variance.
View SourceExponentialWeightedVariance(Double[], Int32, Double, Boolean)
Calculates the exponentially weighted variance.
Declaration
public static double ExponentialWeightedVariance(this double[] values, int window, double alpha = null, bool unbiased = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A vector of observations whose EW variance will be calculated. It is assumed that the vector is ordered with the most recent observations at the end of the vector (and the oldest observations at the start). |
System.Int32 | window | The number of samples to be used in the calculation. |
System.Double | alpha | The weighting to be applied to the calculation. A higher alpha discounts older observations faster. Alpha must be between 0 and 1 (inclusive). |
System.Boolean | unbiased | Use a standard estimation bias correction. |
Returns
Type | Description |
---|---|
System.Double | Returns a |
Examples
The following example shows how to compute the EW variance.
View SourceGeometricMean(Double[])
Computes the Geometric mean of the given values.
Declaration
public static double GeometricMean(this double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The geometric mean of the given data. |
GeometricMean(Int32[])
Computes the geometric mean of the given values.
Declaration
public static double GeometricMean(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The geometric mean of the given data. |
GetHistogramRange(Int32[], Double)
Get range around median of an histogram containing specified percentage of values.
Declaration
public static NumericRange GetHistogramRange(this int[] values, double percent)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
System.Double | percent | Values percentage around median. |
Returns
Type | Description |
---|---|
NumericRange | Returns the range which contains specified percentage of values. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
The method calculates range of stochastic variable, which summary probability comprises the specified percentage of histogram's hits.
GrandMean(Double[], Int32[])
Computes the (weighted) grand mean of a set of samples.
Declaration
public static double GrandMean(double[] means, int[] samples)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | means | A double array containing the sample means. |
System.Int32[] | samples | A integer array containing the sample's sizes. |
Returns
Type | Description |
---|---|
System.Double | The grand mean of the samples. |
HistogramEntropy(Int32[])
Calculate entropy value of an histogram.
Declaration
public static double HistogramEntropy(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Double | Returns entropy value of the specified histogram array. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
HistogramMax(Int32[])
Gets the maximum value in the histogram.
Declaration
public static int HistogramMax(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Int32 | The maximum value in the histogram. |
HistogramMean(Int32[])
Calculate mean value of an histogram.
Declaration
public static double HistogramMean(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Double | Returns mean value. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
HistogramMedian(Int32[])
Calculate median value of an histogram.
Declaration
public static int HistogramMedian(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Int32 | Returns value of median. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
note
The median value is calculated accumulating histogram's values starting from the left point until the sum reaches 50% of histogram's sum.
HistogramMin(Int32[])
Gets the minimum value in the histogram.
Declaration
public static int HistogramMin(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Int32 | The minimum value in the histogram. |
HistogramMode(Int32[])
Calculate mode value of an histogram.
Declaration
public static int HistogramMode(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Int32 | Returns mode value of the histogram array. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
note
Returns the minimum mode value if the specified histogram is multimodal.
HistogramStandardDeviation(Int32[])
Calculate standard deviation of an histogram.
Declaration
public static double HistogramStandardDeviation(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
Returns
Type | Description |
---|---|
System.Double | Returns value of standard deviation. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
HistogramStandardDeviation(Int32[], Double)
Calculate standard deviation of an histogram.
Declaration
public static double HistogramStandardDeviation(this int[] values, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | Histogram array. |
System.Double | mean | Mean value of the histogram. |
Returns
Type | Description |
---|---|
System.Double | Returns value of standard deviation. |
Remarks
The input array is treated as histogram, i.e. its indexes are treated as values of stochastic function, but array values are treated as "probabilities" (total amount of hits).
The method is an equivalent to the HistogramStandardDeviation(Int32[]) method, but it relies on the passed mean value, which is previously calculated using HistogramMean(Int32[]) method.
HistogramSum(Int32[])
Calculates the total number of samples in a histogram.
Declaration
public static long HistogramSum(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | The histogram array. |
Returns
Type | Description |
---|---|
System.Int64 | The total number of samples in the histogram. |
Kurtosis(Double[], Boolean)
Computes the Kurtosis for the given values.
Declaration
public static double Kurtosis(this double[] values, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double | The kurtosis of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
Kurtosis(Double[], Double, Boolean)
Computes the Kurtosis for the given values.
Declaration
public static double Kurtosis(this double[] values, double mean, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double | mean | The values' mean, if already known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double | The kurtosis of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
Kurtosis(Double[][], Boolean)
Computes the Kurtosis vector for the given matrix.
Declaration
public static double[] Kurtosis(this double[][] matrix, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The kurtosis vector of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
Kurtosis(Double[][], Double[], Boolean)
Computes the Kurtosis vector for the given matrix.
Declaration
public static double[] Kurtosis(this double[][] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The kurtosis vector of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
Kurtosis(Double[,], Boolean)
Computes the Kurtosis vector for the given matrix.
Declaration
public static double[] Kurtosis(this double[, ] matrix, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The kurtosis vector of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
Kurtosis(Double[,], Double[], Boolean)
Computes the sample Kurtosis vector for the given matrix.
Declaration
public static double[] Kurtosis(this double[, ] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population kurtosis, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The sample kurtosis vector of the given data. |
Remarks
The framework uses the same definition used by default in SAS and SPSS.
LogGeometricMean(Double[])
Computes the log geometric mean of the given values.
Declaration
public static double LogGeometricMean(this double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The log geometric mean of the given data. |
LogGeometricMean(Int32[])
Computes the log geometric mean of the given values.
Declaration
public static double LogGeometricMean(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The log geometric mean of the given data. |
LowerQuartile(Double[], Boolean, QuantileMethod, Boolean)
Computes the lower quartile (Q1) for the given data.
Declaration
public static double LowerQuartile(this double[] values, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An integer array containing the vector members. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The first quartile of the given data. |
Mean(Double[])
Computes the mean of the given values.
Declaration
public static double Mean(this double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
Mean(Double[][])
Computes the mean value across all dimensions of the given matrix.
Declaration
public static double Mean(this double[][] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix |
Returns
Type | Description |
---|---|
System.Double |
Mean(Double[][], Double[])
Calculates the matrix Mean vector.
Declaration
public static double[] Mean(this double[][] matrix, double[] sums)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Double[] | sums | The sum vector containing already calculated sums for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
Mean(Double[][], Int32)
Calculates the matrix Mean vector.
Declaration
public static double[] Mean(this double[][] matrix, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
Examples
double[][] matrix =
{
new double[] { 2, -1.0, 5 },
new double[] { 7, 0.5, 9 },
};
// column means are equal to (4.5, -0.25, 7.0)
double[] colMeans = Stats.Mean(matrix, 0);
// row means are equal to (2.0, 5.5)
double[] rowMeans = Stats.Mean(matrix, 1);
View Source
Mean(Double[,])
Computes the mean value across all dimensions of the given matrix.
Declaration
public static double Mean(this double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix |
Returns
Type | Description |
---|---|
System.Double |
Mean(Double[,], Double[])
Calculates the matrix Mean vector.
Declaration
public static double[] Mean(this double[, ] matrix, double[] sums)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Double[] | sums | The sum vector containing already calculated sums for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
Mean(Double[,], Int32)
Calculates the matrix Mean vector.
Declaration
public static double[] Mean(this double[, ] matrix, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
Examples
double[,] matrix =
{
{ 2, -1.0, 5 },
{ 7, 0.5, 9 },
};
// column means are equal to (4.5, -0.25, 7.0)
double[] colMeans = Stats.Mean(matrix, 0);
// row means are equal to (2.0, 5.5)
double[] rowMeans = Stats.Mean(matrix, 1);
View Source
Mean(Int32[])
Computes the mean of the given values.
Declaration
public static double Mean(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An integer array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
Mean(Single[])
Computes the mean of the given values.
Declaration
public static float Mean(this float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | A float array containing the vector members. |
Returns
Type | Description |
---|---|
System.Single | The mean of the given data. |
Mean(UInt16[])
Computes the mean of the given values.
Declaration
public static double Mean(this ushort[] values)
Parameters
Type | Name | Description |
---|---|---|
System.UInt16[] | values | A unsigned short array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
Median(Double[], Boolean, QuantileMethod, Boolean)
Computes the Median of the given values.
Declaration
public static double Median(this double[] values, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An integer array containing the vector members. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The median of the given data. |
Median(Double[][], QuantileMethod)
Calculates the matrix Medians vector.
Declaration
public static double[] Median(this double[][] matrix, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose medians will be calculated. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the medians of the given matrix. |
Median(Double[,], QuantileMethod)
Calculates the matrix Medians vector.
Declaration
public static double[] Median(this double[, ] matrix, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose medians will be calculated. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the medians of the given matrix. |
Median(Int32[], Boolean, QuantileMethod, Boolean)
Computes the Median of the given values.
Declaration
public static double Median(this int[] values, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An integer array containing the vector members. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The median of the given data. |
Mode<T>(T[])
Computes the Mode of the given values.
Declaration
public static T Mode<T>(this T[] values)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
Mode<T>(T[], Boolean, Boolean)
Computes the Mode of the given values.
Declaration
public static T Mode<T>(this T[] values, bool inPlace, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
System.Boolean | inPlace | True to perform the operation in place, altering the original input vector. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
Mode<T>(T[], out Int32)
Computes the Mode of the given values.
Declaration
public static T Mode<T>(this T[] values, out int count)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
System.Int32 | count | Returns how many times the detected mode happens in the values. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
Mode<T>(T[], out Int32, Boolean, Boolean)
Computes the Mode of the given values.
Declaration
public static T Mode<T>(this T[] values, out int count, bool inPlace, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
System.Int32 | count | Returns how many times the detected mode happens in the values. |
System.Boolean | inPlace | True to perform the operation in place, altering the original input vector. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
Mode<T>(T[][])
Calculates the matrix Modes vector.
Declaration
public static T[] Mode<T>(this T[][] matrix)
Parameters
Type | Name | Description |
---|---|---|
T[][] | matrix | A matrix whose modes will be calculated. |
Returns
Type | Description |
---|---|
T[] | Returns a vector containing the modes of the given matrix. |
Type Parameters
Name | Description |
---|---|
T |
Mode<T>(T[,])
Calculates the matrix Modes vector.
Declaration
public static T[] Mode<T>(this T[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
T[,] | matrix | A matrix whose modes will be calculated. |
Returns
Type | Description |
---|---|
T[] | Returns a vector containing the modes of the given matrix. |
Type Parameters
Name | Description |
---|---|
T |
PooledCovariance(Double[,][], Double[])
Calculates the weighted pooled covariance matrix from a set of covariance matrices.
Declaration
public static double[, ] PooledCovariance(double[, ][] covariances, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,][] | covariances | |
System.Double[] | weights |
Returns
Type | Description |
---|---|
System.Double[,] |
PooledStandardDeviation(Boolean, Double[][])
Computes the pooled standard deviation of the given values.
Declaration
public static double PooledStandardDeviation(bool unbiased, params double[][] samples)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | unbiased | True to compute a pooled standard deviation using unbiased estimates of the population variance; false otherwise. Default is true. |
System.Double[][] | samples | The grouped samples. |
Returns
Type | Description |
---|---|
System.Double |
PooledStandardDeviation(Double[][])
Computes the pooled standard deviation of the given values.
Declaration
public static double PooledStandardDeviation(params double[][] samples)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | samples | The grouped samples. |
Returns
Type | Description |
---|---|
System.Double |
PooledStandardDeviation(Int32[], Double[], Boolean)
Computes the pooled standard deviation of the given values.
Declaration
public static double PooledStandardDeviation(int[] sizes, double[] variances, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | sizes | The number of samples used to compute the |
System.Double[] | variances | The unbiased variances for the samples. |
System.Boolean | unbiased | True to compute a pooled standard deviation using unbiased estimates of the population variance; false otherwise. Default is true. |
Returns
Type | Description |
---|---|
System.Double |
PooledVariance(Boolean, Double[][])
Computes the pooled variance of the given values.
Declaration
public static double PooledVariance(bool unbiased, params double[][] samples)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | unbiased | True to obtain an unbiased estimate of the population variance; false otherwise. Default is true. |
System.Double[][] | samples | The grouped samples. |
Returns
Type | Description |
---|---|
System.Double |
PooledVariance(Double[][])
Computes the pooled variance of the given values.
Declaration
public static double PooledVariance(params double[][] samples)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | samples | The grouped samples. |
Returns
Type | Description |
---|---|
System.Double |
PooledVariance(Int32[], Double[], Boolean)
Computes the pooled variance of the given values.
Declaration
public static double PooledVariance(int[] sizes, double[] variances, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | sizes | The number of samples used to compute the |
System.Double[] | variances | The unbiased variances for the samples. |
System.Boolean | unbiased | True to obtain an unbiased estimate of the population variance; false otherwise. Default is true. |
Returns
Type | Description |
---|---|
System.Double |
Quantile(Double[], Double, Boolean, QuantileMethod, Boolean)
Computes single quantile for the given sequence.
Declaration
public static double Quantile(this double[] values, double probabilities, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | The sequence of observations. |
System.Double | probabilities | The auantile probability. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quantile type, 1...9. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | Quantile value. |
Quantiles(Double[], Double[], Boolean, QuantileMethod, Boolean)
Computes multiple quantiles for the given sequence.
Declaration
public static double[] Quantiles(this double[] values, double[] probabilities, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | The sequence of observations. |
System.Double[] | probabilities | The sequence of quantile probabilities. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quantile type, 1...9. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double[] | Quantile value. |
Quartiles(Double[], out NumericRange, Boolean, QuantileMethod, Boolean)
Computes the Quartiles of the given values.
Declaration
public static double Quartiles(this double[] values, out NumericRange range, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An integer array containing the vector members. |
NumericRange | range | The inter-quartile range for the values. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The second quartile, the median of the given data. |
Quartiles(Double[], out Double, out Double, Boolean, QuantileMethod, Boolean)
Computes the Quartiles of the given values.
Declaration
public static double Quartiles(this double[] values, out double q1, out double q3, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An integer array containing the vector members. |
System.Double | q1 | The first quartile. |
System.Double | q3 | The third quartile. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The second quartile, the median of the given data. |
Quartiles(Double[][], out NumericRange[], QuantileMethod)
Computes the Quartiles of the given values.
Declaration
public static double[] Quartiles(this double[][] matrix, out NumericRange[] range, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose medians and quartiles will be calculated. |
NumericRange[] | range | The inter-quartile range for the values. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | The second quartile, the median of the given data. |
Quartiles(Double[][], out Double[], out Double[], QuantileMethod)
Computes the Quartiles of the given values.
Declaration
public static double[] Quartiles(double[][] matrix, out double[] q1, out double[] q3, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose medians and quartiles will be calculated. |
System.Double[] | q1 | The first quartile for each column. |
System.Double[] | q3 | The third quartile for each column. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | The second quartile, the median of the given data. |
Quartiles(Double[,], out NumericRange[], QuantileMethod)
Computes the Quartiles of the given values.
Declaration
public static double[] Quartiles(this double[, ] matrix, out NumericRange[] range, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose medians and quartiles will be calculated. |
NumericRange[] | range | The inter-quartile range for the values. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | The second quartile, the median of the given data. |
Quartiles(Double[,], out Double[], out Double[], QuantileMethod)
Computes the Quartiles of the given values.
Declaration
public static double[] Quartiles(double[, ] matrix, out double[] q1, out double[] q3, QuantileMethod type = default(QuantileMethod))
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose medians and quartiles will be calculated. |
System.Double[] | q1 | The first quartile for each column. |
System.Double[] | q3 | The third quartile for each column. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
Returns
Type | Description |
---|---|
System.Double[] | The second quartile, the median of the given data. |
Scatter(Double[][], Double, Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[][] Scatter(this double[][] matrix, double divisor, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double | divisor | A real number to divide each member of the matrix. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[][], Double[])
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[][] Scatter(this double[][] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[][], Double[], Double)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[][] Scatter(this double[][] matrix, double[] means, double divisor)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | divisor | A real number to divide each member of the matrix. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[][], Double[], Double, Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[][] Scatter(double[][] matrix, double[] means, double divisor, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | divisor | A real number to divide each member of the matrix. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[][], Double[], Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[][] Scatter(this double[][] matrix, double[] means, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[][] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[,], Double[])
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] Scatter(this double[, ] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[,], Double[], Double)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] Scatter(this double[, ] matrix, double[] means, double divisor)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | divisor | A real number to divide each member of the matrix. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[,], Double[], Double, Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] Scatter(this double[, ] matrix, double[] means, double divisor, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | divisor | A real number to divide each member of the matrix. |
System.Int32 | dimension | Pass 0 if the mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Scatter(Double[,], Double[], Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] Scatter(this double[, ] matrix, double[] means, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
Skewness(Double[], Boolean)
Computes the Skewness for the given values.
Declaration
public static double Skewness(this double[] values, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
Skewness(Double[], Double, Boolean)
Computes the Skewness for the given values.
Declaration
public static double Skewness(this double[] values, double mean, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double | mean | The values' mean, if already known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
Skewness(Double[][], Boolean)
Computes the Skewness for the given values.
Declaration
public static double[] Skewness(this double[][] matrix, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number matrix containing the matrix values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
Skewness(Double[][], Double[], Boolean)
Computes the Skewness vector for the given matrix.
Declaration
public static double[] Skewness(this double[][] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number array containing the vector values. |
System.Double[] | means | The column means, if known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
Skewness(Double[,], Boolean)
Computes the Skewness for the given values.
Declaration
public static double[] Skewness(this double[, ] matrix, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number matrix containing the matrix values. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
Skewness(Double[,], Double[], Boolean)
Computes the Skewness vector for the given matrix.
Declaration
public static double[] Skewness(this double[, ] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number array containing the vector values. |
System.Double[] | means | The mean value for the given values, if already known. |
System.Boolean | unbiased | True to compute the unbiased estimate of the population skewness, false otherwise. Default is true (compute the unbiased estimator). |
Returns
Type | Description |
---|---|
System.Double[] | The skewness of the given data. |
Remarks
Skewness characterizes the degree of asymmetry of a distribution around its mean. Positive skewness indicates a distribution with an asymmetric tail extending towards more positive values. Negative skewness indicates a distribution with an asymmetric tail extending towards more negative values.
StandardDeviation(Double[], Boolean)
Computes the Standard Deviation of the given values.
Declaration
public static double StandardDeviation(this double[] values, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
StandardDeviation(Double[], Double, Boolean)
Computes the Standard Deviation of the given values.
Declaration
public static double StandardDeviation(this double[] values, double mean, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double | mean | The mean of the vector, if already known. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
StandardDeviation(Double[][], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] StandardDeviation(this double[][] matrix, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
StandardDeviation(Double[][], Double[], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] StandardDeviation(this double[][] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
StandardDeviation(Double[,])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] StandardDeviation(this double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
StandardDeviation(Double[,], Double[])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] StandardDeviation(this double[, ] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
StandardDeviation(Int32[], Double)
Computes the Standard Deviation of the given values.
Declaration
public static double StandardDeviation(this int[] values, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An integer array containing the vector members. |
System.Double | mean | The mean of the vector, if already known. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
StandardDeviation(Single[])
Computes the Standard Deviation of the given values.
Declaration
public static double StandardDeviation(this float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | A double array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
StandardDeviation(Single[], Single)
Computes the Standard Deviation of the given values.
Declaration
public static float StandardDeviation(this float[] values, float mean)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | A float array containing the vector members. |
System.Single | mean | The mean of the vector, if already known. |
Returns
Type | Description |
---|---|
System.Single | The standard deviation of the given data. |
StandardError(Double[])
Computes the Standard Error for a sample size, which estimates the standard deviation of the sample mean based on the population mean.
Declaration
public static double StandardError(double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the samples. |
Returns
Type | Description |
---|---|
System.Double | The standard error for the sample. |
StandardError(Double[,])
Computes the Standard Error vector for a given matrix.
Declaration
public static double[] StandardError(double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A number multi-dimensional array containing the matrix values. |
Returns
Type | Description |
---|---|
System.Double[] | Returns the standard error vector for the matrix. |
StandardError(Int32, Double)
Computes the Standard Error for a sample size, which estimates the standard deviation of the sample mean based on the population mean.
Declaration
public static double StandardError(int samples, double standardDeviation)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samples | The sample size. |
System.Double | standardDeviation | The sample standard deviation. |
Returns
Type | Description |
---|---|
System.Double | The standard error for the sample. |
StandardError(Int32, Double[])
Computes the Standard Error vector for a given matrix.
Declaration
public static double[] StandardError(int samples, double[] standardDeviations)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | samples | The number of samples in the matrix. |
System.Double[] | standardDeviations | The values' standard deviation vector, if already known. |
Returns
Type | Description |
---|---|
System.Double[] | Returns the standard error vector for the matrix. |
TruncatedMean(Double[], Double, Boolean, Boolean)
Computes the truncated (trimmed) mean of the given values.
Declaration
public static double TruncatedMean(this double[] values, double percent, bool inPlace = false, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double | percent | The percentage of observations to drop from the sample. |
System.Boolean | inPlace | Whether to perform operations in place, overwriting the original vector. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
UpperQuartile(Double[], Boolean, QuantileMethod, Boolean)
Computes the upper quartile (Q3) for the given data.
Declaration
public static double UpperQuartile(this double[] values, bool alreadySorted = false, QuantileMethod type = default(QuantileMethod), bool inPlace = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An integer array containing the vector members. |
System.Boolean | alreadySorted | A boolean parameter informing if the given values have already been sorted. |
QuantileMethod | type | The quartile definition that should be used. See QuantileMethod for datails. |
System.Boolean | inPlace | Pass true if the method is allowed to sort |
Returns
Type | Description |
---|---|
System.Double | The third quartile of the given data. |
Variance(Double[])
Computes the Variance of the given values.
Declaration
public static double Variance(this double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double precision number array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Variance(Double[], Boolean)
Computes the Variance of the given values.
Declaration
public static double Variance(this double[] values, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double precision number array containing the vector members. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Variance(Double[], Double)
Computes the Variance of the given values.
Declaration
public static double Variance(this double[] values, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double | mean | The mean of the array, if already known. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Variance(Double[], Double, Boolean)
Computes the Variance of the given values.
Declaration
public static double Variance(this double[] values, double mean, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double | mean | The mean of the array, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Variance(Double[][])
Calculates the matrix Variance vector.
Declaration
public static double[] Variance(this double[][] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
Variance(Double[][], Double[], Boolean)
Calculates the matrix Variance vector.
Declaration
public static double[] Variance(this double[][] matrix, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Variance(Double[,])
Calculates the matrix Variance vector.
Declaration
public static double[] Variance(this double[, ] matrix)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
Variance(Double[,], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] Variance(this double[, ] matrix, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
Variance(Int32[])
Computes the Variance of the given values.
Declaration
public static double Variance(this int[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An integer number array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Variance(Int32[], Boolean)
Computes the Variance of the given values.
Declaration
public static double Variance(this int[] values, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An integer number array containing the vector members. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Variance(Int32[], Double, Boolean)
Computes the Variance of the given values.
Declaration
public static double Variance(this int[] values, double mean, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | A number array containing the vector members. |
System.Double | mean | The mean of the array, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Remarks
Setting unbiased
to true
will make this method
compute the variance σ² using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true
will thus compute σ² using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
Variance(Single[])
Computes the Variance of the given values.
Declaration
public static double Variance(this float[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | A single precision number array containing the vector members. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
Variance(Single[], Single)
Computes the Variance of the given values.
Declaration
public static float Variance(this float[] values, float mean)
Parameters
Type | Name | Description |
---|---|---|
System.Single[] | values | A number array containing the vector members. |
System.Single | mean | The mean of the array, if already known. |
Returns
Type | Description |
---|---|
System.Single | The variance of the given data. |
WeightedCovariance(Double[][], Double[], Double[])
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] WeightedCovariance(this double[][] matrix, double[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean value of the given values, if already known. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
WeightedCovariance(Double[][], Double[], Double[], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] WeightedCovariance(this double[][] matrix, double[] weights, double[] means, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean value of the given values, if already known. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
WeightedCovariance(Double[][], Double[], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] WeightedCovariance(this double[][] matrix, double[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
WeightedCovariance(Double[][], Int32[], Double[], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] WeightedCovariance(this double[][] matrix, int[] weights, double[] means, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
WeightedCovariance(Double[][], Int32[], Int32)
Calculates the covariance matrix of a sample matrix.
Declaration
public static double[, ] WeightedCovariance(this double[][] matrix, int[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
WeightedEntropy(IList<Int32>, IList<Double>, Int32)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(IList<int> values, IList<double> weights, int classes)
Parameters
Type | Name | Description |
---|---|---|
IList<System.Int32> | values | An array of integer symbols. |
IList<System.Double> | weights | The importance for each sample. |
System.Int32 | classes | The number of distinct classes. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedEntropy(IList<Int32>, IList<Double>, Int32, Int32)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(IList<int> values, IList<double> weights, int startValue, int endValue)
Parameters
Type | Name | Description |
---|---|---|
IList<System.Int32> | values | An array of integer symbols. |
IList<System.Double> | weights | The importance for each sample. |
System.Int32 | startValue | The starting symbol. |
System.Int32 | endValue | The ending symbol. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedEntropy(Double[], Double[], Func<Double, Double>)
Computes the entropy function for a set of numerical values in a given Probability Density Function (pdf).
Declaration
public static double WeightedEntropy(this double[] values, double[] weights, Func<double, double> pdf)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double[] | weights | The importance for each sample. |
Func<System.Double, System.Double> | A probability distribution function. |
Returns
Type | Description |
---|---|
System.Double | The distribution's entropy for the given values. |
WeightedEntropy(Double[], Double[], Double, Double)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(double[] values, double[] weights, double startValue, double endValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An array of integer symbols. |
System.Double[] | weights | The importance for each sample. |
System.Double | startValue | The starting symbol. |
System.Double | endValue | The ending symbol. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedEntropy(Double[], Double[], Int32)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(double[] values, double[] weights, int classes)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An array of integer symbols. |
System.Double[] | weights | The importance for each sample. |
System.Int32 | classes | The number of distinct classes. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedEntropy(Double[], Double[], Int32, Int32)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(double[] values, double[] weights, int startValue, int endValue)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | An array of integer symbols. |
System.Double[] | weights | The importance for each sample. |
System.Int32 | startValue | The starting symbol. |
System.Int32 | endValue | The ending symbol. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedEntropy(Double[], Int32[], Func<Double, Double>)
Computes the entropy function for a set of numerical values in a given Probability Density Function (pdf).
Declaration
public static double WeightedEntropy(this double[] values, int[] weights, Func<double, double> pdf)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Int32[] | weights | The repetition counts for each sample. |
Func<System.Double, System.Double> | A probability distribution function. |
Returns
Type | Description |
---|---|
System.Double | The distribution's entropy for the given values. |
WeightedEntropy(Int32[], Double[], Int32)
Computes the entropy for the given values.
Declaration
public static double WeightedEntropy(int[] values, double[] weights, int classes)
Parameters
Type | Name | Description |
---|---|---|
System.Int32[] | values | An array of integer symbols. |
System.Double[] | weights | The importance for each sample. |
System.Int32 | classes | The number of distinct classes. |
Returns
Type | Description |
---|---|
System.Double | The evaluated entropy. |
WeightedMax(Double[], Double[], out Int32, Boolean)
Gets the maximum value in a vector of observations that has a weight higher than zero.
Declaration
public static double WeightedMax(this double[] values, double[] weights, out int imax, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double[] | weights | A vector containing the importance of each sample in |
System.Int32 | imax | The index of the maximum element in the vector, or -1 if it could not be found. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
System.Double | The maximum value in the given data. |
WeightedMax(Double[], Int32[], out Int32, Boolean)
Gets the maximum value in a vector of observations that has a weight higher than zero.
Declaration
public static double WeightedMax(this double[] values, int[] weights, out int imax, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Int32 | imax | The index of the maximum element in the vector, or -1 if it could not be found. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
System.Double | The maximum value in the given data. |
WeightedMean(Double[], Double[])
Computes the Weighted Mean of the given values.
Declaration
public static double WeightedMean(this double[] values, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
WeightedMean(Double[], Int32[])
Computes the Weighted Mean of the given values.
Declaration
public static double WeightedMean(this double[] values, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
Returns
Type | Description |
---|---|
System.Double | The mean of the given data. |
WeightedMean(Double[][], Double[])
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[][] matrix, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Double[] | weights | A vector containing the importance of each sample in the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[][], Double[], Int32)
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[][] matrix, double[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Double[] | weights | A vector containing the importance of each sample in the matrix. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[][], Int32[])
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[][] matrix, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Int32[] | weights | A vector containing the importance of each sample in the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[][], Int32[], Int32)
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[][] matrix, int[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose means will be calculated. |
System.Int32[] | weights | A vector containing the importance of each sample in the matrix. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[,], Double[])
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[, ] matrix, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Double[] | weights | A vector containing the importance of each sample in the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[,], Double[], Int32)
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[, ] matrix, double[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Double[] | weights | A vector containing the importance of each sample in the matrix. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[,], Int32[])
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[, ] matrix, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Int32[] | weights | A vector containing the importance of each sample in the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMean(Double[,], Int32[], Int32)
Calculates the weighted matrix Mean vector.
Declaration
public static double[] WeightedMean(this double[, ] matrix, int[] weights, int dimension = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose means will be calculated. |
System.Int32[] | weights | A vector containing the importance of each sample in the matrix. |
System.Int32 | dimension | The dimension along which the means will be calculated. Pass 0 to compute a row vector containing the mean of each column, or 1 to compute a column vector containing the mean of each row. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the means of the given matrix. |
WeightedMin(Double[], Double[], out Int32, Boolean)
Gets the minimum value in a vector of observations that has a weight higher than zero.
Declaration
public static double WeightedMin(this double[] values, double[] weights, out int imin, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Double[] | weights | A vector containing the importance of each sample in |
System.Int32 | imin | The index of the minimum element in the vector, or -1 if it could not be found. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
System.Double | The minimum value in the given data. |
WeightedMin(Double[], Int32[], out Int32, Boolean)
Gets the minimum value in a vector of observations that has a weight higher than zero.
Declaration
public static double WeightedMin(this double[] values, int[] weights, out int imin, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Int32 | imin | The index of the minimum element in the vector, or -1 if it could not be found. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
System.Double | The minimum value in the given data. |
WeightedMode<T>(T[], Double[], Boolean, Boolean)
Computes the Mode of the given values.
Declaration
public static T WeightedMode<T>(this T[] values, double[] weights, bool inPlace = false, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
System.Double[] | weights | The number of times each sample should be repeated. |
System.Boolean | inPlace | True to perform the operation in place, altering the original input vector. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
WeightedMode<T>(T[], Int32[], Boolean, Boolean)
Computes the Mode of the given values.
Declaration
public static T WeightedMode<T>(this T[] values, int[] weights, bool inPlace = false, bool alreadySorted = false)
Parameters
Type | Name | Description |
---|---|---|
T[] | values | A number array containing the vector values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Boolean | inPlace | True to perform the operation in place, altering the original input vector. |
System.Boolean | alreadySorted | Pass true if the list of values is already sorted. |
Returns
Type | Description |
---|---|
T | The most common value in the given data. |
Type Parameters
Name | Description |
---|---|
T |
WeightedScatter(Double[][], Double[], Double[], Double, Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] WeightedScatter(this double[][] matrix, double[] weights, double[] means, double factor, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | factor | A real number to multiply each member of the matrix. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
WeightedScatter(Double[][], Int32[], Double[], Double, Int32)
Calculates the scatter matrix of a sample matrix.
Declaration
public static double[, ] WeightedScatter(this double[][] matrix, int[] weights, double[] means, double factor, int dimension)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A number multi-dimensional array containing the matrix values. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean value of the given values, if already known. |
System.Double | factor | A real number to multiply each member of the matrix. |
System.Int32 | dimension | Pass 0 to if mean vector is a row vector, 1 otherwise. Default value is 0. |
Returns
Type | Description |
---|---|
System.Double[,] | The covariance matrix. |
Remarks
By dividing the Scatter matrix by the sample size, we get the population Covariance matrix. By dividing by the sample size minus one, we get the sample Covariance matrix.
WeightedStandardDeviation(Double[], Double[])
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Double[], WeightType)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, double[] weights, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Double[], Boolean, WeightType)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, double[] weights, bool unbiased, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Double[], Double)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, double[] weights, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double | mean | The mean of the vector, if already known. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Double[], Double, Boolean, WeightType)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, double[] weights, double mean, bool unbiased, WeightType weightType = WeightType.Fraction)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double | mean | The mean of the vector, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Int32[])
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Int32[], Double)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, int[] weights, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
System.Double | mean | The mean of the vector, if already known. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[], Int32[], Double, Boolean)
Computes the Standard Deviation of the given values.
Declaration
public static double WeightedStandardDeviation(this double[] values, int[] weights, double mean, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A double array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
System.Double | mean | The mean of the vector, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double | The standard deviation of the given data. |
WeightedStandardDeviation(Double[][], Double[], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[][] matrix, double[] weights, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | weights | The number of times each sample should be repeated. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
WeightedStandardDeviation(Double[][], Double[], Double[], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[][] matrix, double[] weights, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
WeightedStandardDeviation(Double[][], Int32[], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[][] matrix, int[] weights, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
WeightedStandardDeviation(Double[][], Int32[], Double[], Boolean)
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[][] matrix, int[] weights, double[] means, bool unbiased = true)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose deviations will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the standard deviation using the sample variance. Pass false to compute it using the population variance. See remarks for more details. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
Remarks
Setting unbiased
to true
will make this method
compute the standard deviation σ using the sample variance, which is an unbiased
estimator of the true population variance. Setting this parameter to true will
thus compute σ using the following formula:
N
σ² = 1 / (N - 1) ∑ (x_i − μ)²
i=1
Setting unbiased
to false
will assume the given values
already represent the whole population, and will compute the population variance
using the formula:
N
σ² = (1 / N) ∑ (x_i − μ)²
i=1
WeightedStandardDeviation(Double[,], Double[])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[, ] matrix, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | weights | The number of times each sample should be repeated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
WeightedStandardDeviation(Double[,], Double[], Double[])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[, ] matrix, double[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
System.Double[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
WeightedStandardDeviation(Double[,], Int32[])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[, ] matrix, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
WeightedStandardDeviation(Double[,], Int32[], Double[])
Calculates the matrix Standard Deviations vector.
Declaration
public static double[] WeightedStandardDeviation(this double[, ] matrix, int[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose deviations will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the standard deviations of the given matrix. |
WeightedVariance(Double[], Double[])
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Double[], WeightType)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Double[], Boolean)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Double[], Boolean, WeightType)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights, bool unbiased, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Double[], Double)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double | mean | The mean of the array, if already known. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Double[], Double, Boolean, WeightType)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, double[] weights, double mean, bool unbiased, WeightType weightType = WeightType.Fraction)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double | mean | The mean of the array, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Int32[])
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Int32[], Boolean)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, int[] weights, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Int32[], Double)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, int[] weights, double mean)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
System.Double | mean | The mean of the array, if already known. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[], Int32[], Double, Boolean)
Computes the weighted Variance of the given values.
Declaration
public static double WeightedVariance(this double[] values, int[] weights, double mean, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | A number array containing the vector members. |
System.Int32[] | weights | A vector containing how many times each element
in |
System.Double | mean | The mean of the array, if already known. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double | The variance of the given data. |
WeightedVariance(Double[][], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[][], Double[], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, double[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[][], Double[], Double[], Boolean, WeightType)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, double[] weights, double[] means, bool unbiased, WeightType weightType = WeightType.Fraction)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[][], Int32[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[][], Int32[], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, int[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[][], Int32[], Double[], Boolean)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[][] matrix, int[] weights, double[] means, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[][] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, double[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Double[], WeightType)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, double[] weights, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Double[], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, double[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Double[], Double[], WeightType)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, double[] weights, double[] means, WeightType weightType)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Double[], Double[], Boolean, WeightType)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, double[] weights, double[] means, bool unbiased, WeightType weightType = WeightType.Fraction)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Double[] | weights | An unit vector containing the importance of each sample
in |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
WeightType | weightType | How the weights should be interpreted for the bias correction. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Int32[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, int[] weights)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Int32[], Double[])
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, int[] weights, double[] means)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |
WeightedVariance(Double[,], Int32[], Double[], Boolean)
Calculates the matrix Variance vector.
Declaration
public static double[] WeightedVariance(this double[, ] matrix, int[] weights, double[] means, bool unbiased)
Parameters
Type | Name | Description |
---|---|---|
System.Double[,] | matrix | A matrix whose variances will be calculated. |
System.Int32[] | weights | The number of times each sample should be repeated. |
System.Double[] | means | The mean vector containing already calculated means for each column of the matrix. |
System.Boolean | unbiased | Pass true to compute the sample variance; or pass false to compute the population variance. For integers weights , the bias correction is equivalent to the non-weighted case. For fractional weights, the variance bias cannot be completely eliminated. |
Returns
Type | Description |
---|---|
System.Double[] | Returns a vector containing the variances of the given matrix. |