source: src/main/java/agents/org/apache/commons/math/distribution/AbstractDistribution.java

Last change on this file was 1, checked in by Wouter Pasman, 7 years ago

Initial import : Genius 9.0.0

File size: 2.6 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package agents.org.apache.commons.math.distribution;
18
19import java.io.Serializable;
20
21import agents.org.apache.commons.math.MathException;
22import agents.org.apache.commons.math.MathRuntimeException;
23import agents.org.apache.commons.math.exception.util.LocalizedFormats;
24
25/**
26 * Base class for probability distributions.
27 *
28 * @version $Revision: 1054524 $ $Date: 2011-01-03 05:59:18 +0100 (lun. 03 janv. 2011) $
29 */
30public abstract class AbstractDistribution
31 implements Distribution, Serializable {
32
33 /** Serializable version identifier */
34 private static final long serialVersionUID = -38038050983108802L;
35
36 /**
37 * Default constructor.
38 */
39 protected AbstractDistribution() {
40 super();
41 }
42
43 /**
44 * For a random variable X whose values are distributed according
45 * to this distribution, this method returns P(x0 ≤ X ≤ x1).
46 * <p>
47 * The default implementation uses the identity</p>
48 * <p>
49 * P(x0 &le; X &le; x1) = P(X &le; x1) - P(X &le; x0) </p>
50 *
51 * @param x0 the (inclusive) lower bound
52 * @param x1 the (inclusive) upper bound
53 * @return the probability that a random variable with this distribution
54 * will take a value between <code>x0</code> and <code>x1</code>,
55 * including the endpoints.
56 * @throws MathException if the cumulative probability can not be
57 * computed due to convergence or other numerical errors.
58 * @throws IllegalArgumentException if <code>x0 > x1</code>
59 */
60 public double cumulativeProbability(double x0, double x1)
61 throws MathException {
62 if (x0 > x1) {
63 throw MathRuntimeException.createIllegalArgumentException(
64 LocalizedFormats.LOWER_ENDPOINT_ABOVE_UPPER_ENDPOINT,
65 x0, x1);
66 }
67 return cumulativeProbability(x1) - cumulativeProbability(x0);
68 }
69}
Note: See TracBrowser for help on using the repository browser.