10package umontreal.ssj.probdistmulti;
12import umontreal.ssj.probdist.NormalDist;
25 private static final double[][] W = {
27 { 0.1713244923791705, 0.3607615730481384, 0.4679139345726904 },
30 { 0.4717533638651177e-1, 0.1069393259953183, 0.1600783285433464, 0.2031674267230659, 0.2334925365383547,
34 { 0.1761400713915212e-1, 0.4060142980038694e-1, 0.6267204833410906e-1, 0.8327674157670475e-1,
35 0.1019301198172404, 0.1181945319615184, 0.1316886384491766, 0.1420961093183821, 0.1491729864726037,
36 0.1527533871307259 } };
38 private static final double[][] X = {
40 { 0.9324695142031522, 0.6612093864662647, 0.2386191860831970 },
43 { 0.9815606342467191, 0.9041172563704750, 0.7699026741943050, 0.5873179542866171, 0.3678314989981802,
47 { 0.9931285991850949, 0.9639719272779138, 0.9122344282513259, 0.8391169718222188, 0.7463319064601508,
48 0.6360536807265150, 0.5108670019508271, 0.3737060887154196, 0.2277858511416451,
49 0.7652652113349733e-1 } };
67 public BiNormalGenzDist(
double mu1,
double sigma1,
double mu2,
double sigma2,
double rho) {
68 super(mu1, sigma1, mu2, sigma2, rho);
82 public static double cdf(
double x,
double y,
double rho) {
83 double bvn = specialCDF(x, y, rho, 40.0);
133 final double TWOPI = 2.0 * Math.PI;
134 final double sqrt2pi = 2.50662827463100050241;
135 double h, k, hk, hs, asr, sn, as, a, b, c, d, sp, rs, ep, bs, xs;
138 if (Math.abs(rho) < 0.3) {
142 }
else if (Math.abs(rho) < 0.75) {
155 if (Math.abs(rho) < 0.925) {
156 hs = (h * h + k * k) / 2.0;
157 asr = Math.asin(rho);
158 for (i = 0; i < lg; ++i) {
159 sn = Math.sin(asr * (1.0 - X[ng][i]) / 2.0);
160 bvn += W[ng][i] * Math.exp((sn * hk - hs) / (1.0 - sn * sn));
161 sn = Math.sin(asr * (1.0 + X[ng][i]) / 2.0);
162 bvn += W[ng][i] * Math.exp((sn * hk - hs) / (1.0 - sn * sn));
171 if (Math.abs(rho) < 1.0) {
172 as = (1.0 - rho) * (1.0 + rho);
174 bs = (h - k) * (h - k);
175 c = (4.0 - hk) / 8.0;
176 d = (12.0 - hk) / 16.0;
177 asr = -(bs / as + hk) / 2.0;
179 bvn = a * Math.exp(asr) * (1.0 - c * (bs - as) * (1.0 - d * bs / 5.0) / 3.0 + c * d * as * as / 5.0);
184 bvn = bvn - Math.exp(-hk / 2.0) * sp * b * (1.0 - c * bs * (1.0 - d * bs / 5.0) / 3.0);
187 for (i = 0; i < lg; ++i) {
188 for (is = -1; is <= 1; is += 2) {
189 xs = (a * (is * X[ng][i] + 1.0));
191 rs = Math.sqrt(1.0 - xs);
192 asr = -(bs / xs + hk) / 2.0;
194 sp = (1.0 + c * xs * (1.0 + d * xs));
195 ep = Math.exp(-hk * (1.0 - rs) / (2.0 * (1.0 + rs))) / rs;
196 bvn += a * W[ng][i] * Math.exp(asr) * (ep - sp);
222 public static double cdf(
double mu1,
double sigma1,
double x,
double mu2,
double sigma2,
double y,
double rho) {
224 throw new IllegalArgumentException(
"sigma1 <= 0");
226 throw new IllegalArgumentException(
"sigma2 <= 0");
227 double Z = (x - mu1) / sigma1;
228 double T = (y - mu2) / sigma2;
229 return cdf(Z, T, rho);
232 public double cdf(
double x,
double y) {
233 return cdf((x - mu1) / sigma1, (y - mu2) / sigma2, rho);
236 public double barF(
double x,
double y) {
237 return barF((x - mu1) / sigma1, (y - mu2) / sigma2, rho);
240 public static double barF(
double mu1,
double sigma1,
double x,
double mu2,
double sigma2,
double y,
double rho) {
242 throw new IllegalArgumentException(
"sigma1 <= 0");
244 throw new IllegalArgumentException(
"sigma2 <= 0");
245 double Z = (x - mu1) / sigma1;
246 double T = (y - mu2) / sigma2;
247 return barF(Z, T, rho);
250 public static double barF(
double x,
double y,
double rho) {
251 return cdf(-x, -y, rho);
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double cdf01(double x)
Same as cdf(0, 1, x).
BiNormalDist(double rho)
Constructs a BiNormalDist object with default parameters , and correlation.
double barF(double x, double y)
Computes the upper cumulative distribution function.
static double barF(double x, double y, double rho)
Computes the standard upper binormal distribution with and .
double cdf(double x, double y)
Computes the distribution function :
static double barF(double mu1, double sigma1, double x, double mu2, double sigma2, double y, double rho)
Computes the upper binormal distribution function ( cdf3binormal ) with parameters = mu1,...
static double cdf(double mu1, double sigma1, double x, double mu2, double sigma2, double y, double rho)
Computes the binormal distribution function ( cdf1binormal ) with parameters = mu1,...
static double cdf(double x, double y, double rho)
Computes the standard binormal distribution ( cdf2binormal ) with the method described in tgen04a .
BiNormalGenzDist(double rho)
Constructs a BiNormalGenzDist object with default parameters.
BiNormalGenzDist(double mu1, double sigma1, double mu2, double sigma2, double rho)
Constructs a BiNormalGenzDist object with parameters = mu1, = mu2, = sigma1,.