Files

26 lines
721 B
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
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;
}
}
}