示例#1
0
        public static double GetQuantile(Gamma gamma, double lowerBound, double upperBound, double probability)
        {
            if (probability < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(probability), "probability < 0");
            }
            if (probability > 1)
            {
                throw new ArgumentOutOfRangeException(nameof(probability), "probability > 1");
            }
            double lowerProbability = gamma.GetProbLessThan(lowerBound);
            double totalProbability = GammaProbBetween(gamma.Shape, gamma.Rate, lowerBound, upperBound);

            return(Math.Min(upperBound, Math.Max(lowerBound, gamma.GetQuantile(probability * totalProbability + lowerProbability))));
        }