mdiggory    2003/06/11 04:14:41

  Modified:    math/src/java/org/apache/commons/math
                        ConvergenceException.java RootFinding.java
                        ContinuedFraction.java
               math/src/java/org/apache/commons/math/stat/distribution
                        GammaDistribution.java
                        ChiSquaredDistributionImpl.java
                        AbstractContinuousDistribution.java
                        FDistribution.java
  Log:
  PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20627
  Submitted by: [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.2       +15 -13    
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ConvergenceException.java
  
  Index: ConvergenceException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ConvergenceException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConvergenceException.java 29 May 2003 19:34:37 -0000      1.1
  +++ ConvergenceException.java 11 Jun 2003 11:14:41 -0000      1.2
  @@ -60,19 +60,21 @@
    * @author Brent Worden
    */
   public class ConvergenceException extends RuntimeException {
  +    /**
  +     * Construct an exception with the given message.
  +     * @param message descriptive error message. 
  +     */
  +    public ConvergenceException(String message) {
  +        super(message);
  +    }
   
  -     /**
  -      * 
  -      */
  -     public ConvergenceException(String message) {
  -             super(message);
  -     }
  -
  -     /**
  -      * 
  -      */
  -     public ConvergenceException(String message, Throwable cause) {
  -             super(message, cause);
  -     }
  +    /**
  +     * Construct an exception with the given message and root cause.
  +     * @param message descriptive error message.
  +     * @param cause root cause.
  +     */
  +    public ConvergenceException(String message, Throwable cause) {
  +        super(message, cause);
  +    }
   
   }
  
  
  
  1.3       +7 -8      
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/RootFinding.java
  
  Index: RootFinding.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/RootFinding.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RootFinding.java  4 Jun 2003 02:17:17 -0000       1.2
  +++ RootFinding.java  11 Jun 2003 11:14:41 -0000      1.3
  @@ -65,7 +65,7 @@
       /**
        * Default constructor. Prohibit construction.
        */
  -    private RootFinding(){
  +    private RootFinding() {
           super();
       }
   
  @@ -83,7 +83,7 @@
       public static double[] bracket(UnivariateFunction function,
                                      double initial,
                                      double lowerBound,
  -                                   double upperBound){
  +                                   double upperBound) {
           return bracket( function, initial, lowerBound, upperBound, 
Integer.MAX_VALUE ) ;
       }
   
  @@ -103,7 +103,7 @@
                                      double initial,
                                      double lowerBound,
                                      double upperBound,
  -                                   int maximumIterations){
  +                                   int maximumIterations) {
           double a = initial;
           double b = initial;
           double fa;
  @@ -132,13 +132,12 @@
        */
       public static double bisection(UnivariateFunction function,
                                      double a,
  -                                   double b){
  +                                   double b) {
           double m;
           double fm;
           double fa;
   
  -        if ( b < a )
  -        {
  +        if ( b < a ) {
               double xtemp = a ;
               a = b ;
               b = xtemp ;
  @@ -146,11 +145,11 @@
   
           fa = function.evaluate(a);
   
  -        while(Math.abs(a - b) > EPSILON){
  +        while(Math.abs(a - b) > EPSILON) {
               m = (a + b) * 0.5;  // midpoint
               fm = function.evaluate(m);
   
  -            if(fm * fa > 0.0){
  +            if(fm * fa > 0.0) {
                   // b and m bracket the root.
                   a = m;
                   fa = fm;
  
  
  
  1.2       +21 -15    
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ContinuedFraction.java
  
  Index: ContinuedFraction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/ContinuedFraction.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContinuedFraction.java    11 Jun 2003 01:19:19 -0000      1.1
  +++ ContinuedFraction.java    11 Jun 2003 11:14:41 -0000      1.2
  @@ -71,12 +71,12 @@
       /** Maximum allowed numerical error. */
       private static final double DEFAULT_EPSILON = 10e-9;
       
  -     /**
  -      * Default constructor.
  -      */
  -     protected ContinuedFraction() {
  -             super();
  -     }
  +    /**
  +     * Default constructor.
  +     */
  +    protected ContinuedFraction() {
  +        super();
  +    }
       
       /**
        * Access the n-th a coefficient of the continued fraction.  Since a can be
  @@ -101,7 +101,7 @@
        * @param x the evaluation point.
        * @return the value of the continued fraction evaluated at x. 
        */
  -    public double evaluate(double x){
  +    public double evaluate(double x) {
           return evaluate(x, DEFAULT_EPSILON, Integer.MAX_VALUE);
       }    
       
  @@ -111,7 +111,7 @@
        * @param epsilon maximum error allowed.
        * @return the value of the continued fraction evaluated at x. 
        */
  -    public double evaluate(double x, double epsilon){
  +    public double evaluate(double x, double epsilon) {
           return evaluate(x, epsilon, Integer.MAX_VALUE);
       }    
       
  @@ -121,7 +121,7 @@
        * @param maxIterations maximum number of convergents
        * @return the value of the continued fraction evaluated at x. 
        */
  -    public double evaluate(double x, int maxIterations){
  +    public double evaluate(double x, int maxIterations) {
           return evaluate(x, DEFAULT_EPSILON, maxIterations);
       }    
       
  @@ -159,7 +159,8 @@
       }
       
       /**
  -     * Evaluates the n-th convergent, fn = pn / qn, for this continued fraction at 
the value x.
  +     * Evaluates the n-th convergent, fn = pn / qn, for this continued fraction
  +     * at the value x.
        * @param n the convergent to compute.
        * @param x the evaluation point.
        * @param a (n-1)-th convergent matrix.  (Input)
  @@ -167,9 +168,11 @@
        * @param f the n-th convergent matrix. (Output)
        * @param epsilon maximum error allowed.
        * @param maxIterations maximum number of convergents
  -     * @return the value of the the n-th convergent for this continued fraction 
evaluated at x. 
  +     * @return the value of the the n-th convergent for this continued fraction
  +     *         evaluated at x. 
        */
  -    private double evaluate(int n, double x, double[][] a, double[][] an, 
double[][] f, double epsilon, int maxIterations) {
  +    private double evaluate(int n, double x, double[][] a, double[][] an,
  +            double[][] f, double epsilon, int maxIterations) {
           double ret;
           
           // create next matrix
  @@ -185,14 +188,17 @@
           f[1][1] = (a[1][0] * an[0][1]) + (a[1][1] * an[1][1]);
           
           // determine if we're close enough
  -        if(Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) < Math.abs(epsilon * 
f[1][0] * f[1][1])){
  +        if(Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) <
  +                Math.abs(epsilon * f[1][0] * f[1][1])){
               ret = f[0][0] / f[1][0];
           } else {
               if(n >= maxIterations){
  -                throw new ConvergenceException("Continued fraction convergents 
failed to converge.");
  +                throw new ConvergenceException(
  +                    "Continued fraction convergents failed to converge.");
               }
               // compute next
  -            ret = evaluate(n + 1, x, f /* new a */, an /* reuse an */, a /* new f 
*/, epsilon, maxIterations);
  +            ret = evaluate(n + 1, x, f /* new a */, an /* reuse an */,
  +                            a /* new f */, epsilon, maxIterations);
           }
           
           return ret;
  
  
  
  1.4       +1 -1      
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistribution.java
  
  Index: GammaDistribution.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/GammaDistribution.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GammaDistribution.java    5 Jun 2003 14:02:28 -0000       1.3
  +++ GammaDistribution.java    11 Jun 2003 11:14:41 -0000      1.4
  @@ -60,7 +60,7 @@
    * 
    * <p>
    * Instances of GammaDistribution objects should be created using
  - * [EMAIL PROTECTED] DistributionFactory#createGammaDistribution(double)}
  + * [EMAIL PROTECTED] DistributionFactory#createGammaDistribution(double,double)}
    * </p>
    * 
    * <p>
  
  
  
  1.4       +59 -6     
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ChiSquaredDistributionImpl.java
  
  Index: ChiSquaredDistributionImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/ChiSquaredDistributionImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ChiSquaredDistributionImpl.java   5 Jun 2003 14:02:29 -0000       1.3
  +++ ChiSquaredDistributionImpl.java   11 Jun 2003 11:14:41 -0000      1.4
  @@ -1,3 +1,56 @@
  +/* ====================================================================
  + * The Apache Software License, Version 1.1
  + *
  + * Copyright (c) 2003 The Apache Software Foundation.  All rights
  + * reserved.
  + *
  + * Redistribution and use in source and binary forms, with or without
  + * modification, are permitted provided that the following conditions
  + * are met:
  + *
  + * 1. Redistributions of source code must retain the above copyright
  + *    notice, this list of conditions and the following disclaimer.
  + *
  + * 2. Redistributions in binary form must reproduce the above copyright
  + *    notice, this list of conditions and the following disclaimer in
  + *    the documentation and/or other materials provided with the
  + *    distribution.
  + *
  + * 3. The end-user documentation included with the redistribution, if
  + *    any, must include the following acknowlegement:
  + *       "This product includes software developed by the
  + *        Apache Software Foundation (http://www.apache.org/)."
  + *    Alternately, this acknowlegement may appear in the software itself,
  + *    if and wherever such third-party acknowlegements normally appear.
  + *
  + * 4. The names "The Jakarta Project", "Commons", and "Apache Software
  + *    Foundation" must not be used to endorse or promote products derived
  + *    from this software without prior written permission. For written
  + *    permission, please contact [EMAIL PROTECTED]
  + *
  + * 5. Products derived from this software may not be called "Apache"
  + *    nor may "Apache" appear in their names without prior written
  + *    permission of the Apache Software Foundation.
  + *
  + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  + * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  + * SUCH DAMAGE.
  + * ====================================================================
  + *
  + * This software consists of voluntary contributions made by many
  + * individuals on behalf of the Apache Software Foundation.  For more
  + * information on the Apache Software Foundation, please see
  + * <http://www.apache.org/>.
  + */
   package org.apache.commons.math.stat.distribution;
   
   /**
  @@ -16,7 +69,7 @@
        * Create a Chi-Squared distribution with the given degrees of freedom.
        * @param degreesOfFreedom degrees of freedom.
        */
  -    public ChiSquaredDistributionImpl(double degreesOfFreedom){
  +    public ChiSquaredDistributionImpl(double degreesOfFreedom) {
           super();
           setGamma(DistributionFactory.newInstance().createGammaDistribution(
               degreesOfFreedom / 2.0, 2.0));
  @@ -56,7 +109,7 @@
        * @return domain value lower bound, i.e.
        *         P(X &lt; <i>lower bound</i>) &lt; <code>p</code> 
        */
  -    protected double getDomainLowerBound(double p){
  +    protected double getDomainLowerBound(double p) {
           return Double.MIN_VALUE * getGamma().getBeta();
       }
   
  @@ -69,13 +122,13 @@
        * @return domain value upper bound, i.e.
        *         P(X &lt; <i>upper bound</i>) &gt; <code>p</code> 
        */
  -    protected double getDomainUpperBound(double p){
  +    protected double getDomainUpperBound(double p) {
           // NOTE: chi squared is skewed to the left
           // NOTE: therefore, P(X < &mu;) > .5
   
           double ret;
   
  -        if(p < .5){
  +        if (p < .5) {
               // use mean
               ret = getDegreesOfFreedom();
           } else {
  @@ -94,13 +147,13 @@
        * @param p the desired probability for the critical value
        * @return initial domain value
        */
  -    protected double getInitialDomain(double p){
  +    protected double getInitialDomain(double p) {
           // NOTE: chi squared is skewed to the left
           // NOTE: therefore, P(X < &mu;) > .5
           
           double ret;
   
  -        if(p < .5){
  +        if (p < .5) {
               // use 1/2 mean
               ret = getDegreesOfFreedom() * .5;
           } else {
  
  
  
  1.3       +2 -2      
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/AbstractContinuousDistribution.java
  
  Index: AbstractContinuousDistribution.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/AbstractContinuousDistribution.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AbstractContinuousDistribution.java       5 Jun 2003 14:02:29 -0000       1.2
  +++ AbstractContinuousDistribution.java       11 Jun 2003 11:14:41 -0000      1.3
  @@ -93,8 +93,8 @@
        * @param p the desired probability
        * @return x, such that P(X &lt; x) = <code>p</code>
        */
  -    public double inverseCummulativeProbability(final double p){
  -        if(p < 0.0 || p > 1.0){
  +    public double inverseCummulativeProbability(final double p) {
  +        if (p < 0.0 || p > 1.0){
               throw new IllegalArgumentException(
                   "p must be between 0.0 and 1.0, inclusive.");
           }
  
  
  
  1.2       +1 -1      
jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistribution.java
  
  Index: FDistribution.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/distribution/FDistribution.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FDistribution.java        11 Jun 2003 01:19:19 -0000      1.1
  +++ FDistribution.java        11 Jun 2003 11:14:41 -0000      1.2
  @@ -60,7 +60,7 @@
    * 
    * <p>
    * Instances of FDistribution objects should be created using
  - * [EMAIL PROTECTED] DistributionFactory#createFDistribution(double)}
  + * [EMAIL PROTECTED] DistributionFactory#createFDistribution(double,double)}
    * </p>
    * 
    * <p>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to