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 */
17 package org.apache.commons.math.distribution;
18
19 /**
20 * Base interface for continuous distributions.
21 *
22 * @version $Id: ContinuousDistribution.java 1178295 2011-10-03 04:36:27Z psteitz $
23 */
24 public interface ContinuousDistribution extends Distribution {
25 /**
26 * For a distribution, {@code X}, compute {@code x} such that
27 * {@code P(X < x) = p}.
28 *
29 * @param p Cumulative probability.
30 * @return {@code x} such that {@code P(X < x) = p}.
31 */
32 double inverseCumulativeProbability(double p);
33
34 /**
35 * Probability density for a particular point.
36 *
37 * @param x Point at which the density should be computed.
38 * @return the pdf at point {@code x}.
39 */
40 double density(double x);
41
42 /**
43 * Reseed the random generator used to generate samples.
44 *
45 * @param seed New seed.
46 * @since 3.0
47 */
48 void reseedRandomGenerator(long seed);
49
50 /**
51 * Generate a random value sampled from this distribution.
52 *
53 * @return a random value.
54 * @since 3.0
55 */
56 double sample();
57
58 /**
59 * Generate a random sample from the distribution.
60 *
61 * @param sampleSize number of random values to generate.
62 * @return an array representing the random sample.
63 * @throws org.apache.commons.math.exception.NotStrictlyPositiveException
64 * if {@code sampleSize} is not positive.
65 * @since 3.0
66 */
67 double[] sample(int sampleSize);
68 }