001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.commons.math.distribution;
018
019 import org.apache.commons.math.MathException;
020
021 /**
022 * Base interface for probability distributions.
023 *
024 * @version $Revision: 1054524 $ $Date: 2011-01-03 05:59:18 +0100 (lun. 03 janv. 2011) $
025 */
026 public interface Distribution {
027 /**
028 * For a random variable X whose values are distributed according
029 * to this distribution, this method returns P(X ≤ x). In other words,
030 * this method represents the (cumulative) distribution function, or
031 * CDF, for this distribution.
032 *
033 * @param x the value at which the distribution function is evaluated.
034 * @return the probability that a random variable with this
035 * distribution takes a value less than or equal to <code>x</code>
036 * @throws MathException if the cumulative probability can not be
037 * computed due to convergence or other numerical errors.
038 */
039 double cumulativeProbability(double x) throws MathException;
040
041 /**
042 * For a random variable X whose values are distributed according
043 * to this distribution, this method returns P(x0 ≤ X ≤ x1).
044 *
045 * @param x0 the (inclusive) lower bound
046 * @param x1 the (inclusive) upper bound
047 * @return the probability that a random variable with this distribution
048 * will take a value between <code>x0</code> and <code>x1</code>,
049 * including the endpoints
050 * @throws MathException if the cumulative probability can not be
051 * computed due to convergence or other numerical errors.
052 * @throws IllegalArgumentException if <code>x0 > x1</code>
053 */
054 double cumulativeProbability(double x0, double x1) throws MathException;
055
056 }