View Javadoc

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 org.apache.commons.math.MathException;
19  
20  /**
21   * Base interface for probability distributions.
22   *
23   * @version $Revision: 155427 $ $Date: 2005-02-26 06:11:52 -0700 (Sat, 26 Feb 2005) $
24   */
25  public interface Distribution {
26      /**
27       * For a random variable X whose values are distributed according
28       * to this distribution, this method returns P(X ≤ x).  In other words,
29       * this method represents the  (cumulative) distribution function, or
30       * CDF, for this distribution.
31       * 
32       * @param x the value at which the distribution function is evaluated.
33       * @return the probability that a random variable with this
34       * distribution takes a value less than or equal to <code>x</code>
35       * @throws MathException if the cumulative probability can not be
36       * computed due to convergence or other numerical errors.
37       */
38      double cumulativeProbability(double x) throws MathException;
39      
40      /**
41       * For a random variable X whose values are distributed according
42       * to this distribution, this method returns P(x0 &le; X &le; x1).
43       * 
44       * @param x0 the (inclusive) lower bound
45       * @param x1 the (inclusive) upper bound
46       * @return the probability that a random variable with this distribution
47       * will take a value between <code>x0</code> and <code>x1</code>, 
48       * including the endpoints
49       * @throws MathException if the cumulative probability can not be
50       * computed due to convergence or other numerical errors.
51       * @throws IllegalArgumentException if <code>x0 > x1</code>
52       */
53      double cumulativeProbability(double x0, double x1) throws MathException;
54  }