From de8c2adc648839ad0ae234ccb22a0d4a5db3b6dd Mon Sep 17 00:00:00 2001 From: Brent Worden Date: Thu, 7 Jun 2007 13:44:09 +0000 Subject: [PATCH] Removed dependency on DistributionFactory. Added settable gamma distribution field. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@545179 13f79535-47bb-0310-9956-ffa450edef68 --- .../ChiSquaredDistributionImpl.java | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java b/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java index fdf39ee6a..d2ed85071 100644 --- a/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java +++ b/src/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java @@ -37,12 +37,22 @@ public class ChiSquaredDistributionImpl /** * Create a Chi-Squared distribution with the given degrees of freedom. - * @param degreesOfFreedom degrees of freedom. + * @param df degrees of freedom. */ - public ChiSquaredDistributionImpl(double degreesOfFreedom) { + public ChiSquaredDistributionImpl(double df) { + this(df, new GammaDistributionImpl(df / 2.0, 2.0)); + } + + /** + * Create a Chi-Squared distribution with the given degrees of freedom. + * @param df degrees of freedom. + * @param g the underlying gamma distribution used to compute probabilities. + * @since 1.2 + */ + public ChiSquaredDistributionImpl(double df, GammaDistribution g) { super(); - setGamma(DistributionFactory.newInstance().createGammaDistribution( - degreesOfFreedom / 2.0, 2.0)); + setGamma(g); + setDegreesOfFreedom(df); } /** @@ -161,11 +171,14 @@ public class ChiSquaredDistributionImpl } /** - * Modify the Gamma distribution. - * @param gamma the new distribution. + * Modify the underlying gamma distribution. The caller is responsible for + * insuring the gamma distribution has the proper parameter settings. + * @param g the new distribution. + * @since 1.2 made public */ - private void setGamma(GammaDistribution gamma) { - this.gamma = gamma; + public void setGamma(GammaDistribution g) { + this.gamma = g; + } /**