/// <summary> /// Initializes a new normal distribution with the given mean and standard deviation. /// </summary> /// <param name="mu">The mean.</param> /// <param name="sigma">The standard deviation, which must be positive.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="sigma"/> is less than or equal to zero.</exception> public NormalDistribution(double mu, double sigma) { if (sigma <= 0.0) throw new ArgumentOutOfRangeException("sigma"); this.mu = mu; this.sigma = sigma; this.normalRng = DeviateGeneratorFactory.GetNormalGenerator(); }
public BetaFromGammaGenerator(IDeviateGenerator alphaGenerator, IDeviateGenerator betaGenerator) { Debug.Assert(alphaGenerator != null); Debug.Assert(betaGenerator != null); this.alphaGenerator = alphaGenerator; this.betaGenerator = betaGenerator; }
/// <summary> /// Initializes a new Cauchy distribution. /// </summary> /// <param name="mu">The centroid of the distribution.</param> /// <param name="gamma">The width parameter of the distribution.</param> public CauchyDistribution(double mu, double gamma) { if (gamma <= 0.0) throw new ArgumentNullException("gamma"); this.mu = mu; this.gamma = gamma; this.cauchyRng = DeviateGeneratorFactory.GetCauchyGenerator(); }
public BetaFromGammaGenerator(IDeviateGenerator alphaGenerator, IDeviateGenerator betaGenerator) { if (alphaGenerator == null) throw new ArgumentNullException("alphaGenerator"); if (betaGenerator == null) throw new ArgumentNullException("betaGenerator"); this.alphaGenerator = alphaGenerator; this.betaGenerator = betaGenerator; }
public MarsagliaTsangGammaGenerator(IDeviateGenerator normalGenerator, double alpha) { Debug.Assert(alpha >= 1.0); this.normalGenerator = normalGenerator; a = alpha; a1 = a - 1.0 / 3.0; a2 = 1.0 / Math.Sqrt(9.0 * a1); }
/// <summary> /// Initializes a new normal distribution with the given mean and standard deviation. /// </summary> /// <param name="mu">The mean.</param> /// <param name="sigma">The standard deviation, which must be positive.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="sigma"/> is less than or equal to zero.</exception> public NormalDistribution(double mu, double sigma) { if (sigma <= 0.0) { throw new ArgumentOutOfRangeException(nameof(sigma)); } this.mu = mu; this.sigma = sigma; this.normalRng = DeviateGeneratorFactory.GetNormalGenerator(); }
public MarsagliaTsangGammaGenerator(IDeviateGenerator normalGenerator, double alpha) { if (alpha < 1.0) { throw new ArgumentOutOfRangeException("alpha"); } this.normalGenerator = normalGenerator; a = alpha; a1 = a - 1.0 / 3.0; a2 = 1.0 / Math.Sqrt(9.0 * a1); }
public BetaFromGammaGenerator(IDeviateGenerator alphaGenerator, IDeviateGenerator betaGenerator) { if (alphaGenerator == null) { throw new ArgumentNullException("alphaGenerator"); } if (betaGenerator == null) { throw new ArgumentNullException("betaGenerator"); } this.alphaGenerator = alphaGenerator; this.betaGenerator = betaGenerator; }
/// <summary> /// Initializes a new β distribution. /// </summary> /// <param name="alpha">The left shape parameter, which controls the form of the distribution near x=0.</param> /// <param name="beta">The right shape parameter, which controls the form of the distribution near x=1.</param> /// <remarks> /// <para>The <paramref name="alpha"/> shape parameter controls the form of the distribution near x=0. The /// <paramref name="beta"/> shape parameter controls the form of the distribution near z=1. If a shape parameter /// is less than one, the PDF diverges on the side of the distribution it controls. If a shape parameter /// is greater than one, the PDF goes to zero on the side of the distribution it controls. If the left and right /// shapre parameters are equal, the distribution is symmetric about x=1/2.</para> /// </remarks> /// <seealso href="http://en.wikipedia.org/wiki/Beta_distribution" /> public BetaDistribution(double alpha, double beta) { if (alpha <= 0.0) throw new ArgumentOutOfRangeException("alpha"); if (beta <= 0.0) throw new ArgumentOutOfRangeException("beta"); this.alpha = alpha; this.beta = beta; // cache value of B(alpha, beta) to avoid having to re-calculate it whenever needed this.bigB = AdvancedMath.Beta(alpha, beta); // get a beta generator this.betaRng = DeviateGeneratorFactory.GetBetaGenerator(alpha, beta); // get a beta inverter this.betaInverter = new BetaInverter(alpha, beta); }
/// <summary> /// Initializes a new instance of a Gamma distribution with the given parameters. /// </summary> /// <param name="shape">The shape parameter, which must be positive.</param> /// <param name="scale">The scale parameter, which must be positive.</param> public GammaDistribution(double shape, double scale) { if (shape <= 0.0) throw new ArgumentOutOfRangeException("shape"); if (scale <= 0.0) throw new ArgumentOutOfRangeException("scale"); a = shape; s = scale; // depending on size of a, store Gamma(a) or -Ln(Gamma(a)) for future use if (a < 64.0) { ga = AdvancedMath.Gamma(a); } else { ga = -AdvancedMath.LogGamma(a); } gammaRng = DeviateGeneratorFactory.GetGammaGenerator(a); }
public MarsagliaTsangGammaGenerator(IDeviateGenerator normalGenerator, double alpha) { if (alpha < 1.0) throw new ArgumentOutOfRangeException("alpha"); this.normalGenerator = normalGenerator; a = alpha; a1 = a - 1.0 / 3.0; a2 = 1.0 / Math.Sqrt(9.0 * a1); }