25package umontreal.ssj.probdistmulti.norta;
27import umontreal.ssj.probdistmulti.*;
28import umontreal.ssj.probdist.*;
83 protected double mu1, mu2, sd1, sd2;
97 private String tabToString(
double[] tab, String message) {
98 String desc = message +
"\n [";
99 for (
int i = 0; i < tab.length; i++)
100 if (i == tab.length - 1)
103 desc += tab[i] +
",";
143 m1 = dist1.inverseFInt(tr) + 1;
144 m2 = dist2.inverseFInt(tr) + 1;
146 int[] y1 =
new int[m1];
147 int[] y2 =
new int[m2];
151 double[] f1 =
new double[m1];
152 double[] f2 =
new double[m2];
155 double u11 = 0.0, u22 = 0.0;
158 for (
int i = 0; i < m1; i++) {
160 p1[i] = dist1.prob(y1[i]);
161 f1[i] = dist1.cdf(y1[i]);
163 if (z1[i] == Double.NEGATIVE_INFINITY)
165 if (z1[i] == Double.POSITIVE_INFINITY)
167 mu1 += f1[i] * p1[i];
168 u11 += f1[i] * f1[i] * p1[i];
170 sd1 = Math.sqrt(u11 - mu1 * mu1);
173 for (
int i = 0; i < m2; i++) {
175 p2[i] = dist2.prob(y2[i]);
176 f2[i] = dist2.cdf(y2[i]);
178 if (z2[i] == Double.NEGATIVE_INFINITY)
180 if (z2[i] == Double.POSITIVE_INFINITY)
182 mu2 += f2[i] * p2[i];
183 u22 += f2[i] * f2[i] * p2[i];
185 sd2 = Math.sqrt(u22 - mu2 * mu2);
210 for (
int i = 0; i < m1 - 1; i++) {
212 for (
int j = 0; j < m2 - 1; j++) {
215 gr += p1[i + 1] * sum;
235 double c = Math.sqrt(1.0 - r * r);
236 double c1 = 2 * c * c;
239 for (
int i = 0; i < m1 - 1; i++) {
240 double z1sq = z1[i] * z1[i];
241 double t1 = 2 * r * z1[i];
243 for (
int j = 0; j < m2 - 1; j++) {
244 sum += p2[j + 1] * Math.exp((t1 * z2[j] - z1sq - z2[j] * z2[j]) / c1);
246 gp += p1[i + 1] * sum;
248 gp = gp / (2.0 * Math.PI * c);
252 public String toString() {
254 desc +=
"rX = " + rX +
"\n";
255 desc +=
"tr = " + tr +
"\n";
256 desc +=
"m1 = " + m1 +
"\n";
257 desc +=
"m2 = " + m2 +
"\n";
258 desc +=
"mu1 = " + mu1 +
"\n";
259 desc +=
"mu2 = " + mu2 +
"\n";
260 desc +=
"sd1 = " + sd1 +
"\n";
261 desc +=
"sd2 = " + sd2 +
"\n";
262 desc += tabToString(p1,
"Table p1 : ");
263 desc += tabToString(z1,
"Table z1 : ");
264 desc += tabToString(p2,
"Table p2 : ");
265 desc += tabToString(z2,
"Table z2 : ");
Classes implementing discrete distributions over the integers should inherit from this class.
Extends the class ContinuousDistribution for the normal distribution (e.g., tjoh95a (page 80)).
static double inverseF01(double u)
Same as inverseF(0, 1, u).
Extends the class BiNormalDist for the bivariate normal distribution tjoh72a (page 84) using a trans...
static double barF(double mu1, double sigma1, double x, double mu2, double sigma2, double y, double rho, int ndig)
Computes the upper binormal distribution function ( cdf3binormal ) with parameters = mu1,...
NortaInitDisc(double rX, DiscreteDistributionInt dist1, DiscreteDistributionInt dist2, double tr)
Constructor with the target rank correlation rX, the two discrete marginals dist1 and dist2 and the p...
double deriv(double r)
Computes the derivative of , given by.
void computeParams()
Computes the following inputs of each marginal distribution:
abstract double computeCorr()
Computes and returns the correlation .
double integ(double r)
Computes the function.