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    /**
020     * Base interface for probability distributions.
021     *
022     * @version $Id: Distribution.java 1178295 2011-10-03 04:36:27Z psteitz $
023     */
024    public interface Distribution {
025        /**
026         * For a random variable X whose values are distributed according
027         * to this distribution, this method returns P(X ≤ x).  In other words,
028         * this method represents the  (cumulative) distribution function, or
029         * CDF, for this distribution.
030         *
031         * @param x the value at which the distribution function is evaluated.
032         * @return the probability that a random variable with this
033         * distribution takes a value less than or equal to <code>x</code>
034         */
035        double cumulativeProbability(double x);
036    
037        /**
038         * For a random variable X whose values are distributed according
039         * to this distribution, this method returns P(x0 &le; X &le; x1).
040         *
041         * @param x0 the (inclusive) lower bound
042         * @param x1 the (inclusive) upper bound
043         * @return the probability that a random variable with this distribution
044         * will take a value between <code>x0</code> and <code>x1</code>,
045         * including the endpoints
046         * @throws IllegalArgumentException if <code>x0 > x1</code>
047         */
048        double cumulativeProbability(double x0, double x1);
049    
050        /**
051         * Use this method to get the numerical value of the mean of this
052         * distribution.
053         *
054         * @return the mean or Double.NaN if it's not defined
055         */
056        double getNumericalMean();
057    
058        /**
059         * Use this method to get the numerical value of the variance of this
060         * distribution.
061         *
062         * @return the variance (possibly Double.POSITIVE_INFINITY as
063         * for certain cases in {@link TDistributionImpl}) or
064         * Double.NaN if it's not defined
065         */
066        double getNumericalVariance();
067    
068        /**
069         * Use this method to get information about whether the lower bound
070         * of the support is inclusive or not.
071         *
072         * @return whether the lower bound of the support is inclusive or not
073         */
074        boolean isSupportLowerBoundInclusive();
075    
076        /**
077         * Use this method to get information about whether the upper bound
078         * of the support is inclusive or not.
079         *
080         * @return whether the upper bound of the support is inclusive or not
081         */
082        boolean isSupportUpperBoundInclusive();
083    
084        /**
085         * Use this method to get information about whether the support is connected,
086         * i.e. whether all values between the lower and upper bound of the support
087         * is included in the support.
088         *
089         * For {@link AbstractIntegerDistribution} the support is discrete, so
090         * if this is true, then the support is
091         * {lower bound, lower bound + 1, ..., upper bound}.
092         *
093         * For {@link AbstractContinuousDistribution} the support is continuous, so
094         * if this is true, then the support is the interval
095         * [lower bound, upper bound]
096         * where the limits are inclusive or not according to
097         * {@link #isSupportLowerBoundInclusive()} and {@link #isSupportUpperBoundInclusive()}
098         * (in the example both are true). If both are false, then the support is the interval
099         * (lower bound, upper bound)
100         *
101         * @return whether the support limits given by subclassed methods are connected or not
102         */
103        boolean isSupportConnected();
104    }