This is an automated email from the ASF dual-hosted git repository.
aherbert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-statistics.git
The following commit(s) were added to refs/heads/master by this push:
new f685029 ChiSquaredDistribution: Use the gamma distribution to create
a sampler.
f685029 is described below
commit f685029b9c6eb33f090e084e4ed96faa11cd0b93
Author: Alex Herbert <[email protected]>
AuthorDate: Wed Oct 2 23:32:50 2019 +0100
ChiSquaredDistribution: Use the gamma distribution to create a sampler.
---
.../distribution/ChiSquaredDistribution.java | 31 ++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ChiSquaredDistribution.java
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ChiSquaredDistribution.java
index 3407cc6..e012281 100644
---
a/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ChiSquaredDistribution.java
+++
b/commons-statistics-distribution/src/main/java/org/apache/commons/statistics/distribution/ChiSquaredDistribution.java
@@ -16,6 +16,8 @@
*/
package org.apache.commons.statistics.distribution;
+import org.apache.commons.rng.UniformRandomProvider;
+
/**
* Implementation of the <a
href="http://en.wikipedia.org/wiki/Chi-squared_distribution">chi-squared
distribution</a>.
*/
@@ -116,4 +118,33 @@ public class ChiSquaredDistribution extends
AbstractContinuousDistribution {
public boolean isSupportConnected() {
return true;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * Sampling algorithms:
+ * <ul>
+ * <li>
+ * For {@code 0 < degreesOfFreedom < 2}:
+ * <blockquote>
+ * Ahrens, J. H. and Dieter, U.,
+ * <i>Computer methods for sampling from gamma, beta, Poisson and
binomial distributions,</i>
+ * Computing, 12, 223-246, 1974.
+ * </blockquote>
+ * </li>
+ * <li>
+ * For {@code degreesOfFreedom >= 2}:
+ * <blockquote>
+ * Marsaglia and Tsang, <i>A Simple Method for Generating
+ * Gamma Variables.</i> ACM Transactions on Mathematical Software,
+ * Volume 26 Issue 3, September, 2000.
+ * </blockquote>
+ * </li>
+ * </ul>
+ */
+ @Override
+ public ContinuousDistribution.Sampler createSampler(final
UniformRandomProvider rng) {
+ return gamma.createSampler(rng);
+ }
}