Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 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);
        }