Beispiel #1
0
        private static double RelativeError <T>(QuantifiedValueOptions <T> options, List <double> stats)
        {
            var(mean, deviation) = stats.MeanStandardDeviation();
            var sem = deviation / Math.Sqrt(stats.Count);
            var marginOfErrorInPercents = sem * ConfidenceToFactor[options.ConfidenceLevel] / mean;

            return(marginOfErrorInPercents);
        }
Beispiel #2
0
        private static double AbsoluteError <T>(QuantifiedValueOptions <T> options, List <double> stats)
        {
            var deviation     = stats.StandardDeviation();
            var sem           = deviation / Math.Sqrt(stats.Count);
            var marginOfError = sem * ConfidenceToFactor[options.ConfidenceLevel];

            return(marginOfError);
        }
Beispiel #3
0
        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);
        }