private static double RelativeError <T>(QuantifiedValueOptions <T> options, List <double> stats) { var(mean, deviation) = Statistics.MeanStandardDeviation(stats); var sem = deviation / Math.Sqrt(stats.Count); var marginOfErrorInPercents = sem * ConfidenceToFactor[options.ConfidenceLevel] / mean; return(marginOfErrorInPercents); }
private static double AbsoluteError <T>(QuantifiedValueOptions <T> options, List <double> stats) { var deviation = Statistics.StandardDeviation(stats); var sem = deviation / Math.Sqrt(stats.Count); var marginOfError = sem * ConfidenceToFactor[options.ConfidenceLevel]; return(marginOfError); }
private static bool IsGoodEnough <T>(QuantifiedValueOptions <T> valueOptions, List <T> batchRunResults) { var stats = batchRunResults.Select(runResult => valueOptions.GetQuantifiedValue(runResult)).ToList(); var isNiceRelativeError = !valueOptions.DesiredRelativeError.HasValue || RelativeError(valueOptions, stats) <= valueOptions.DesiredRelativeError; var isNiceAbsoluteError = !valueOptions.DesiredAbsoluteError.HasValue || AbsoluteError(valueOptions, stats) <= valueOptions.DesiredAbsoluteError; return(isNiceRelativeError && isNiceAbsoluteError); }