public Range GetRange(double[] a, double[] b, double margin)
        {
            if (margin < 0 || margin > 0.5)
            {
                throw new ArgumentOutOfRangeException(nameof(margin), $"{nameof(margin)} should be inside [0;0.5]");
            }
            int minQuantile   = Math.Min(50, (int)Math.Round(margin * 100));
            int maxQuantile   = 100 - minQuantile;
            var probabilities = new double[maxQuantile - minQuantile + 1];

            for (int i = 0; i < probabilities.Length; i++)
            {
                probabilities[i] = (minQuantile + i) / 100.0;
            }
            var quantileValues = distributionCompareFunction.Values(a, b, probabilities);

            return(Range.Of(quantileValues.Min(), quantileValues.Max()));
        }
Example #2
0
        protected static void Run(DistributionCompareOptions options, DistributionCompareFunction function)
        {
            var x = options.GetSourceArray1();
            var y = options.GetSourceArray2();

            if (string.IsNullOrEmpty(options.Probabilities))
            {
                var rangeEstimator = new DistributionCompareRangeEstimator(function);
                if (options.Margin.HasValue)
                {
                    Console.WriteLine(rangeEstimator.GetRange(x, y, options.Margin.Value).ToString());
                }
                else
                {
                    Console.WriteLine(rangeEstimator.GetRange(x, y).ToString());
                }
            }
            else
            {
                var probabilities = options.ConvertStringToArray(options.Probabilities, "probabilities");
                Console.WriteLine(string.Join(";", function.Values(x, y, probabilities)));
            }
        }