SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
ContinuousDistribution2Dim.java
1/*
2 * Class: ContinuousDistribution2Dim
3 * Description: Mother class 2-dimensional continuous distributions
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.probdistmulti;
26
27import umontreal.ssj.util.PrintfFormat;
28import umontreal.ssj.util.Num;
29
45
51 public int decPrec = 15;
52
53 // x infinity for some distributions
54 protected static final double XINF = Double.MAX_VALUE;
55
56 // x infinity for some distributions
57 protected static final double XBIG = 1000.0;
58
59 // EPSARRAY[j]: Epsilon required for j decimal degits of precision
60 protected static final double[] EPSARRAY = { 0.5, 0.5E-1, 0.5E-2, 0.5E-3, 0.5E-4, 0.5E-5, 0.5E-6, 0.5E-7, 0.5E-8,
61 0.5E-9, 0.5E-10, 0.5E-11, 0.5E-12, 0.5E-13, 0.5E-14, 0.5E-15, 0.5E-16, 0.5E-17, 0.5E-18, 0.5E-19, 0.5E-20,
62 0.5E-21, 0.5E-22, 0.5E-23, 0.5E-24, 0.5E-25, 0.5E-26, 0.5E-27, 0.5E-28, 0.5E-29, 0.5E-30, 0.5E-31, 0.5E-32,
63 0.5E-33, 0.5E-34, 0.5E-35 };
64
72 public abstract double density(double x, double y);
73
80 public double density(double[] x) {
81 if (x.length != 2)
82 throw new IllegalArgumentException("x must be in dimension 2");
83
84 return density(x[0], x[1]);
85 }
86
95 public abstract double cdf(double x, double y);
96
106 public double barF(double x, double y) {
107 double u = 1.0 + cdf(x, y) - cdf(XINF, y) - cdf(x, XINF);
108 if (u <= 0.0)
109 return 0.0;
110 if (u >= 1.0)
111 return 1.0;
112 return u;
113 }
114
126 public double cdf(double a1, double a2, double b1, double b2) {
127 if (a1 >= b1 || a2 >= b2)
128 return 0.0;
129 return cdf(b1, b2) - cdf(a1, b2) - cdf(b1, a2) + cdf(a1, a2);
130 }
131
132}
Classes implementing 2-dimensional continuous distributions should inherit from this class.
abstract double cdf(double x, double y)
Computes the distribution function :
double density(double[] x)
Simply calls density (x[0], x[1]).
int decPrec
Defines the target number of decimals of accuracy when approximating a distribution function,...
abstract double density(double x, double y)
Returns , the density of evaluated at .
double barF(double x, double y)
Computes the upper cumulative distribution function.
double cdf(double a1, double a2, double b1, double b2)
Computes the cumulative probability in the square region.
Classes implementing continuous multi-dimensional distributions should inherit from this class.