Files
DP44/Common/DTS.Common.Utilities/.svn/pristine/12/1222de73700fde656a8a142fc695e8c9957b0d8a.svn-base
2026-04-17 14:55:32 -04:00

26 lines
721 B
Plaintext

using System.Collections.Generic;
using System.Linq;
namespace DTS.Utilities
{
public class StandardDev
{
public static double StandardDeviation(IEnumerable<double> values)
{
double standardDeviation = 0;
if (!values.Any()) return standardDeviation;
// Compute the average.
double avg = values.Average();
// Perform the Sum of (value-avg)_2_2.
double sum = values.Sum(d => System.Math.Pow(d - avg, 2));
// Put it all together.
standardDeviation = System.Math.Sqrt((sum) / (values.Count() - 1));
return standardDeviation;
}
}
}