20 lines
707 B
C#
20 lines
707 B
C#
using System.Collections.Generic;
|
|
|
|
namespace DTS.Utilities
|
|
{
|
|
public static class SignalToNoiseRatio
|
|
{
|
|
/// <summary>
|
|
/// Calculates Noise given a full scale peak-to-peak
|
|
/// </summary>
|
|
/// <param name="values">Data set</param>
|
|
/// <param name="fullScalePP">The full scale peak-to-peak of the data set; 65536.0 by default for ADC data</param>
|
|
/// <returns></returns>
|
|
public static double CalculateSNR(IEnumerable<double> values, double fullScalePP = 65536.0)
|
|
{
|
|
var stdDev = StandardDev.StandardDeviation(values);
|
|
return -20 * System.Math.Log10(3.0 * stdDev / fullScalePP);
|
|
}
|
|
}
|
|
}
|