/// <summary> /// Generates a sequence of samples from the distribution. /// </summary> /// <param name="rnd">The random number generator to use.</param> /// <param name="shape">The shape (α) of the distribution. Range: α > 0.</param> /// <param name="scale">The scale (β) of the distribution. Range: β > 0.</param> /// <returns>a sequence of samples from the distribution.</returns> public static IEnumerable <double> Samples(System.Random rnd, double shape, double scale) { if (shape <= 0.0 || scale <= 0.0) { throw new ArgumentOutOfRangeException(Resources.InvalidDistributionParameters); } return(Gamma.Samples(rnd, shape, scale).Select(z => 1.0 / z)); }
/// <summary> /// Fills an array with samples generated from the distribution. /// </summary> /// <param name="values">The array to fill with the samples.</param> /// <param name="shape">The shape (k) of the Erlang distribution. Range: k ≥ 0.</param> /// <param name="rate">The rate or inverse scale (λ) of the Erlang distribution. Range: λ ≥ 0.</param> /// <returns>a sequence of samples from the distribution.</returns> public static void Samples(double[] values, int shape, double rate) { Gamma.Samples(values, shape, rate); }
/// <summary> /// Generates a sequence of samples from the distribution. /// </summary> /// <param name="shape">The shape (k) of the Erlang distribution. Range: k ≥ 0.</param> /// <param name="rate">The rate or inverse scale (λ) of the Erlang distribution. Range: λ ≥ 0.</param> /// <returns>a sequence of samples from the distribution.</returns> public static IEnumerable <double> Samples(int shape, double rate) { return(Gamma.Samples(shape, rate)); }
/// <summary> /// Fills an array with samples generated from the distribution. /// </summary> /// <param name="rnd">The random number generator to use.</param> /// <param name="values">The array to fill with the samples.</param> /// <param name="shape">The shape (k) of the Erlang distribution. Range: k ≥ 0.</param> /// <param name="rate">The rate or inverse scale (λ) of the Erlang distribution. Range: λ ≥ 0.</param> /// <returns>a sequence of samples from the distribution.</returns> public static void Samples(System.Random rnd, double[] values, int shape, double rate) { Gamma.Samples(rnd, values, shape, rate); }
/// <summary> /// Generates a sequence of samples from the distribution. /// </summary> /// <param name="rnd">The random number generator to use.</param> /// <param name="shape">The shape (k) of the Erlang distribution. Range: k ≥ 0.</param> /// <param name="rate">The rate or inverse scale (λ) of the Erlang distribution. Range: λ ≥ 0.</param> /// <returns>a sequence of samples from the distribution.</returns> public static IEnumerable <double> Samples(System.Random rnd, int shape, double rate) { return(Gamma.Samples(rnd, shape, rate)); }
/// <summary> /// Generates a sequence of samples from the Cauchy distribution. /// </summary> /// <returns>a sequence of samples from the distribution.</returns> public IEnumerable <double> Samples() { return(Gamma.Samples(_random, _shape, _scale).Select(z => 1.0 / z)); }