Sample variance and sample standard deviation
1. Definition: The average of the difference between the data in the sample and the average of the sample is called the sample variance, and the arithmetic square root of the sample variance is called the sample standard deviation.
Note: Both the sample variance and the sample standard deviation measure the amount of a sample's fluctuation, the larger the sample variance or sample standard deviation, the greater the fluctuation of the sample data.
Standard deviation and standard variance
1. Definition: Variance is the average of the square sum of the difference between the data and the average. In probability and mathematical statistics, variance is used to measure the degree of deviation between the random variable and its mathematical expectation (i.e. mean value). Standard deviation is most commonly used as a measure of statistical distribution in probability statistics. The standard deviation is defined as the arithmetic square root of variance, which reflects the degree of dispersion among the individuals in the group.
Weighted average
1, definition: The weighted average number (weighted average) is the average of different gravity data, that is, the original data according to a reasonable proportion of the calculation.
The algorithm code is as follows:
public static double Standarddeviation (this ilist<double> source) {if (Source = null)
{throw new ArgumentNullException ("source"); } if source. Count = = 0) {return double.
NaN; Double variance = source.
Variance ();
return math.sqrt (variance); public static double Samplestandarddeviation (this ilist<double> source) {if (sou
RCE = = null) {throw new ArgumentNullException ("source"); } if source. Count = 0 | | Source. Count = = 1) {return double.
NaN; Double variance = source.
Samplevariance ();
return math.sqrt (variance);
public static double variance (this ilist<double> source) {if (Source = null) {throw new ArgumentNullException ("source"); } if source. Count = = 0) {return double.
NaN; int count = source.
Count ();
Double deviation = calculatedeviation (source, count);
return deviation/count; public static double Samplevariance (this ilist<double> source) {if (Source = = Nu
LL) {throw new ArgumentNullException ("source");; } if source. Count = 0 | | Source. Count = = 1) {return double.
NaN; int count = source.
Count ();
Double deviation = calculatedeviation (source, count);
Return deviation/(count-1);
public static double Weightedaverage (this ilist<double> source, ilist<double> factors) {if (Source = =NULL) {throw new ArgumentNullException ("source"); } if source. Count!= factors.
Count) {throw new ArgumentException ("Source count isn't equal to factors count."); } if source. Count = = 0) {return double.
NaN; Double sum = factors.
Sum (); if (sum = = 0) {return double.
NaN;
Double weight = 0; for (int index = 0; index < factors. Count;
index++) {weight + = Source[index] * (Factors[index]/sum);
return weight; private static double calculatedeviation (ilist<double> source, int count) {Doubl e avg = source.
Average ();
Double deviation = 0;
for (int index = 0; index < count; index++) {deviation + = (Source[index]-avg) * (Source[index]-avg);
return deviation; }
The above is used more in the financial aspect ...