/// <summary> /// Returns the logarithm base 10 of the root mean square of the given samples. /// </summary> /// <param name="samples">The samples.</param> /// <returns>The calculated log root mean square in log 10.</returns> public static double LogRootMeanSquare(double[] samples) { Debug.Assert(samples.Length > 0); double sumOfSquares = 0.0f; foreach (double sample in samples) { sumOfSquares += sample * sample; } double rootMeanSquare = Math.Sqrt(sumOfSquares / samples.Length); rootMeanSquare = Math.Max(rootMeanSquare, 1); return(LogMath.Log10((float)rootMeanSquare) * 20); }