diff --git a/PeyrSharp.Core/Maths/Stats.cs b/PeyrSharp.Core/Maths/Stats.cs index a6701bf..394affe 100644 --- a/PeyrSharp.Core/Maths/Stats.cs +++ b/PeyrSharp.Core/Maths/Stats.cs @@ -165,5 +165,20 @@ public static double Variance(List values) int n = values.Count; return variance / (n - 1); } + + /// + /// Calculates the standard deviation of a list of double numbers. + /// + /// The list of double numbers. + /// The standard deviation of the list of double numbers. + /// Thrown when the list is null or empty. + public static double StandardDeviation(List values) + { + if (values == null || values.Count == 0) + { + throw new ArgumentException("The list cannot be null or empty.", nameof(values)); + } + return Math.Sqrt(Variance(values)); + } } }