Coverage Report - org.apache.commons.math.distribution.AbstractDistribution

Classes in this File Line Coverage Branch Coverage Complexity
AbstractDistribution
100% 
100% 
2

 1  
 /*
 2  
  * Copyright 2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.apache.commons.math.distribution;
 17  
 
 18  
 import java.io.Serializable;
 19  
 
 20  
 import org.apache.commons.math.MathException;
 21  
 
 22  
 /**
 23  
  * Base class for probability distributions.   
 24  
  *  
 25  
  * @version $Revision$ $Date: 2005-02-26 05:11:52 -0800 (Sat, 26 Feb 2005) $
 26  
  */
 27  
 public abstract class AbstractDistribution
 28  
     implements Distribution, Serializable {
 29  
 
 30  
     /** Serializable version identifier */
 31  
     static final long serialVersionUID = -38038050983108802L;
 32  
     
 33  
     /**
 34  
      * Default constructor.
 35  
      */
 36  
     protected AbstractDistribution() {
 37  650
         super();
 38  650
     }
 39  
 
 40  
     /**
 41  
      * For a random variable X whose values are distributed according
 42  
      * to this distribution, this method returns P(x0 ≤ X ≤ x1).
 43  
      * <p>
 44  
      * The default implementation uses the identity
 45  
      * <p>
 46  
      * P(x0 &le; X &le; x1) = P(X &le; x1) - P(X &le; x0)
 47  
      * 
 48  
      * @param x0 the (inclusive) lower bound
 49  
      * @param x1 the (inclusive) upper bound
 50  
      * @return the probability that a random variable with this distribution
 51  
      * will take a value between <code>x0</code> and <code>x1</code>,
 52  
      * including the endpoints.
 53  
      * @throws MathException if the cumulative probability can not be
 54  
      * computed due to convergence or other numerical errors.
 55  
      * @throws IllegalArgumentException if <code>x0 > x1</code>
 56  
      */
 57  
     public double cumulativeProbability(double x0, double x1)
 58  
         throws MathException {
 59  442
         if (x0 > x1) {
 60  16
             throw new IllegalArgumentException
 61  
             ("lower endpoint must be less than or equal to upper endpoint");
 62  
         }
 63  426
         return cumulativeProbability(x1) - cumulativeProbability(x0);
 64  
     }
 65  
 }