diff --git a/src/Numerics/Distributions/Bernoulli.cs b/src/Numerics/Distributions/Bernoulli.cs
index 89f8c3c8..a46a385d 100644
--- a/src/Numerics/Distributions/Bernoulli.cs
+++ b/src/Numerics/Distributions/Bernoulli.cs
@@ -321,5 +321,25 @@ namespace MathNet.Numerics.Distributions
}
}
+ ///
+ /// Samples a Bernoulli distributed random variable.
+ ///
+ /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
+ /// A sample from the Bernoulli distribution.
+ public static int Sample(double p)
+ {
+ return Sample(SystemRandomSource.Default, p);
+ }
+
+ ///
+ /// Samples a sequence of Bernoulli distributed random variables.
+ ///
+ /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
+ /// a sequence of samples from the distribution.
+ public static IEnumerable Samples(double p)
+ {
+ return Samples(SystemRandomSource.Default, p);
+ }
+
}
}
diff --git a/src/Numerics/Distributions/Binomial.cs b/src/Numerics/Distributions/Binomial.cs
index adfd5446..1926a6cf 100644
--- a/src/Numerics/Distributions/Binomial.cs
+++ b/src/Numerics/Distributions/Binomial.cs
@@ -360,5 +360,29 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, p, n);
}
}
+
+ ///
+ /// Samples a binomially distributed random variable.
+ ///
+ /// The random number generator to use.
+ /// The success probability (p) in each trial. Range: 0 ≤ p ≤ 1.
+ /// The number of trials (n). Range: n ≥ 0.
+ /// The number of successes in trials.
+ public static int Sample(double p, int n)
+ {
+ return Sample(SystemRandomSource.Default, p, n);
+ }
+
+ ///
+ /// Samples a sequence of binomially distributed random variable.
+ ///
+ /// The random number generator to use.
+ /// The success probability (p) in each trial. Range: 0 ≤ p ≤ 1.
+ /// The number of trials (n). Range: n ≥ 0.
+ /// a sequence of successes in trials.
+ public static IEnumerable Samples(double p, int n)
+ {
+ return Samples(SystemRandomSource.Default, p, n);
+ }
}
}
diff --git a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
index 96c37876..d03a05d2 100644
--- a/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
+++ b/src/Numerics/Distributions/ConwayMaxwellPoisson.cs
@@ -521,5 +521,25 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, lambda, nu, z);
}
}
+
+ ///
+ /// Samples a random variable.
+ ///
+ /// The lambda (λ) parameter. Range: λ > 0.
+ /// The rate of decay (ν) parameter. Range: ν ≥ 0.
+ public static int Sample(double lambda, double nu)
+ {
+ return Sample(SystemRandomSource.Default, lambda, nu);
+ }
+
+ ///
+ /// Samples a sequence of this random variable.
+ ///
+ /// The lambda (λ) parameter. Range: λ > 0.
+ /// The rate of decay (ν) parameter. Range: ν ≥ 0.
+ public static IEnumerable Samples(double lambda, double nu)
+ {
+ return Samples(SystemRandomSource.Default, lambda, nu);
+ }
}
}
diff --git a/src/Numerics/Distributions/DiscreteUniform.cs b/src/Numerics/Distributions/DiscreteUniform.cs
index b9355fd1..2667fe2a 100644
--- a/src/Numerics/Distributions/DiscreteUniform.cs
+++ b/src/Numerics/Distributions/DiscreteUniform.cs
@@ -328,5 +328,27 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, lower, upper);
}
}
+
+ ///
+ /// Samples a uniformly distributed random variable.
+ ///
+ /// Lower bound. Range: lower ≤ upper.
+ /// Upper bound. Range: lower ≤ upper.
+ /// A sample from the discrete uniform distribution.
+ public static int Sample(int lower, int upper)
+ {
+ return Sample(SystemRandomSource.Default, lower, upper);
+ }
+
+ ///
+ /// Samples a sequence of uniformly distributed random variables.
+ ///
+ /// Lower bound. Range: lower ≤ upper.
+ /// Upper bound. Range: lower ≤ upper.
+ /// a sequence of samples from the discrete uniform distribution.
+ public static IEnumerable Samples(int lower, int upper)
+ {
+ return Samples(SystemRandomSource.Default, lower, upper);
+ }
}
}
diff --git a/src/Numerics/Distributions/Geometric.cs b/src/Numerics/Distributions/Geometric.cs
index 815cdd75..200d1ff4 100644
--- a/src/Numerics/Distributions/Geometric.cs
+++ b/src/Numerics/Distributions/Geometric.cs
@@ -297,5 +297,23 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, p);
}
}
+
+ ///
+ /// Samples a random variable.
+ ///
+ /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
+ public static int Sample(double p)
+ {
+ return Sample(SystemRandomSource.Default, p);
+ }
+
+ ///
+ /// Samples a sequence of this random variable.
+ ///
+ /// The probability (p) of generating one. Range: 0 ≤ p ≤ 1.
+ public static IEnumerable Samples(double p)
+ {
+ return Samples(SystemRandomSource.Default, p);
+ }
}
}
diff --git a/src/Numerics/Distributions/Hypergeometric.cs b/src/Numerics/Distributions/Hypergeometric.cs
index 156f8742..dbb1f345 100644
--- a/src/Numerics/Distributions/Hypergeometric.cs
+++ b/src/Numerics/Distributions/Hypergeometric.cs
@@ -387,5 +387,27 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, population, success, draws);
}
}
+
+ ///
+ /// Samples a random variable.
+ ///
+ /// The size of the population (N).
+ /// The number successes within the population (K, M).
+ /// The number of draws without replacement (n).
+ public static int Sample(int population, int success, int draws)
+ {
+ return Sample(SystemRandomSource.Default, population, success, draws);
+ }
+
+ ///
+ /// Samples a sequence of this random variable.
+ ///
+ /// The size of the population (N).
+ /// The number successes within the population (K, M).
+ /// The number of draws without replacement (n).
+ public static IEnumerable Samples(int population, int success, int draws)
+ {
+ return Samples(SystemRandomSource.Default, population, success, draws);
+ }
}
}
diff --git a/src/Numerics/Distributions/NegativeBinomial.cs b/src/Numerics/Distributions/NegativeBinomial.cs
index ad8bb6f2..3b57fe0b 100644
--- a/src/Numerics/Distributions/NegativeBinomial.cs
+++ b/src/Numerics/Distributions/NegativeBinomial.cs
@@ -325,5 +325,25 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, r, p);
}
}
+
+ ///
+ /// Samples a random variable.
+ ///
+ /// The number of failures (r) until the experiment stopped. Range: r ≥ 0.
+ /// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
+ public static int Sample(double r, double p)
+ {
+ return Sample(SystemRandomSource.Default, r, p);
+ }
+
+ ///
+ /// Samples a sequence of this random variable.
+ ///
+ /// The number of failures (r) until the experiment stopped. Range: r ≥ 0.
+ /// The probability (p) of a trial resulting in success. Range: 0 ≤ p ≤ 1.
+ public static IEnumerable Samples(double r, double p)
+ {
+ return Samples(SystemRandomSource.Default, r, p);
+ }
}
}
diff --git a/src/Numerics/Distributions/Poisson.cs b/src/Numerics/Distributions/Poisson.cs
index a5529f2b..26d41cb7 100644
--- a/src/Numerics/Distributions/Poisson.cs
+++ b/src/Numerics/Distributions/Poisson.cs
@@ -352,5 +352,25 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, lambda);
}
}
+
+ ///
+ /// Samples a Poisson distributed random variable.
+ ///
+ /// The lambda (λ) parameter of the Poisson distribution. Range: λ > 0.
+ /// A sample from the Poisson distribution.
+ public static int Sample(double lambda)
+ {
+ return Sample(SystemRandomSource.Default, lambda);
+ }
+
+ ///
+ /// Samples a sequence of Poisson distributed random variables.
+ ///
+ /// The lambda (λ) parameter of the Poisson distribution. Range: λ > 0.
+ /// a sequence of samples from the distribution.
+ public static IEnumerable Samples(double lambda)
+ {
+ return Samples(SystemRandomSource.Default, lambda);
+ }
}
}
diff --git a/src/Numerics/Distributions/Zipf.cs b/src/Numerics/Distributions/Zipf.cs
index 0784d672..531d402d 100644
--- a/src/Numerics/Distributions/Zipf.cs
+++ b/src/Numerics/Distributions/Zipf.cs
@@ -363,5 +363,25 @@ namespace MathNet.Numerics.Distributions
yield return SampleUnchecked(rnd, s, n);
}
}
+
+ ///
+ /// Samples a random variable.
+ ///
+ /// The s parameter of the distribution.
+ /// The n parameter of the distribution.
+ public static int Sample(double s, int n)
+ {
+ return Sample(SystemRandomSource.Default, s, n);
+ }
+
+ ///
+ /// Samples a sequence of this random variable.
+ ///
+ /// The s parameter of the distribution.
+ /// The n parameter of the distribution.
+ public static IEnumerable Samples(double s, int n)
+ {
+ return Samples(SystemRandomSource.Default, s, n);
+ }
}
}