/// <inheritdoc/> public double GetProbLessThan(double x) { if (this.IsPointMass) { return((this.Point < x) ? 1.0 : 0.0); } else { double totalProbability = Gamma.GetProbBetween(LowerBound, UpperBound); return(Gamma.GetProbBetween(LowerBound, x) / totalProbability); } }
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 = gamma.GetProbBetween(lowerBound, upperBound); return(Math.Min(upperBound, Math.Max(lowerBound, gamma.GetQuantile(probability * totalProbability + lowerProbability)))); }