/// <inheritdoc/> public override double InverseLeftProbability(double P) { if ((P < 0.0) || (P > 1.0)) { throw new ArgumentOutOfRangeException(nameof(P)); } return(Math.Sqrt(2.0 * gamma.InverseLeftProbability(P))); }
/// <inheritdoc /> public override double InverseLeftProbability(double P) { return(2.0 * gamma.InverseLeftProbability(P)); }
public void TimeGammaGenerators() { double alpha = 1.0; Random rng = new Random(1); //IDeviateGenerator nRng = new AhrensDieterGammaGenerator(alpha); IDeviateGenerator nRng = new MarsagliaTsangGammaGenerator(new PolarRejectionNormalDeviateGenerator(), alpha); Distribution d = new GammaDistribution(alpha); //double sum = 0.0; Sample sample = new Sample(); Stopwatch timer = Stopwatch.StartNew(); for (int i = 0; i < 1000000; i++) { //double x = nRng.GetNext(rng); double x = d.InverseLeftProbability(rng.NextDouble()); //sum += x; sample.Add(x); } timer.Stop(); Console.WriteLine(sample.KolmogorovSmirnovTest(d).RightProbability); //Console.WriteLine(sum); Console.WriteLine(timer.ElapsedMilliseconds); }