SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscShiftBaker1Lattice.java
1/*
2 * Class: DiscShiftBaker1Lattice
3 * Description: computes a discrepancy for the randomly shifted, then baker
4 folded points of an integration lattice
5 * Environment: Java
6 * Software: SSJ
7 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
8 * Organization: DIRO, Universite de Montreal
9 * @author Richard Simard
10 * @since January 2009
11
12 * SSJ is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU General Public License (GPL) as published by the
14 * Free Software Foundation, either version 3 of the License, or
15 * any later version.
16
17 * SSJ is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21
22 * A copy of the GNU General Public License is available at
23 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
24 */
25package umontreal.ssj.discrepancy;
26
27import umontreal.ssj.hups.Rank1Lattice;
28
62 static final double TRENTEUN24 = 31.0 / 24.0;
63 static final double SEPT24 = 7.0 / 24.0;
64
65 private static double computeFactor(double x, double C1, double C2, double C3) {
66 // Compute 1 factor of the product with Cr = C[r], r = 1,2,3, and x =
67 // Point[i][r]
68 // This is a simplified form of computeFactor1.
69
70 double pol1; // Bernoulli(4, u) - Bernoulli(4, v)
71 double pol2; // 7*Bernoulli(4, u) - 2*Bernoulli(4, v)
72 double pol3; // Bernoulli(6, u) - Bernoulli(6, v)
73 double temp;
74
75 if (x >= 0.5) {
76 // v = x - 0.5;
77 pol1 = -0.5625 + x * (3.0 - x * (4.5 - 2.0 * x));
78 pol2 = -TRENTEUN24 + x * (6.0 - x * (4.0 + x * (6.0 - 5.0 * x)));
79 temp = 1.0 + x * (-6.0 + 4.0 * x);
80 pol3 = 0.046875 * temp * temp * (4.0 * x - 3.0);
81 } else {
82 // v = x + 0.5;
83 pol1 = -0.0625 + x * x * (1.5 - 2.0 * x);
84 pol2 = -SEPT24 + x * x * (8.0 - x * (14.0 - 5.0 * x));
85 temp = 1.0 + x * (2.0 - 4.0 * x);
86 pol3 = -0.046875 * temp * temp * (4.0 * x - 1.0);
87 }
88
89 temp = C1 * pol1 + C2 * pol2 + C3 * pol3;
90 return temp;
91 }
92
98 public DiscShiftBaker1Lattice(double[][] points, int n, int s) {
99 super(points, n, s);
100 }
101
107 public DiscShiftBaker1Lattice(double[][] points, int n, int s, double[] gamma) {
108 super(points, n, s, gamma);
109 }
110
117 public DiscShiftBaker1Lattice(int n, int s, double[] gamma) {
118 super(n, s, gamma);
119 }
120
126 super(set);
127 }
128
134 }
135
142 public double compute(double[][] points, int n, int s) {
143 setONES(s);
144 return compute(points, n, s, ONES);
145 }
146
153 public double compute(double[][] points, int n, int s, double[] gamma) {
154 double[] C1 = new double[s];
155 double[] C2 = new double[s];
156 double[] C3 = new double[s];
157 setC(C1, C2, C3, gamma, s);
158 double prod, fact;
159 int r;
160
161 double sum = 0.0;
162 for (int i = 0; i < n; ++i) {
163 prod = 1.0;
164 for (r = 0; r < s; ++r) {
165 fact = computeFactor(points[i][r], C1[r], C2[r], C3[r]);
166 prod *= 1.0 - fact;
167 }
168 sum += prod;
169 }
170 double disc = sum / n - 1.0;
171 if (disc < 0.0) // Lost all precision: result meaningless
172 return -1.0;
173 return Math.sqrt(disc);
174 }
175
182 public double compute(double[] T, int n) {
183 return compute(T, n, 1.);
184 }
185
192 public double compute(double[] T, int n, double gamma) {
193 double[] C = setC(gamma);
194 double C1 = C[0];
195 double C2 = C[1];
196 double C3 = C[2];
197
198 double sum = 0.0;
199 for (int i = 0; i < n; ++i) {
200 double h = T[i];
201 double pol1 = ((h - 2.0) * h + 1.0) * h * h - UNTRENTE; // Bernoulli(4,h)
202 double v = h - 0.5;
203 if (v < 0.0)
204 v += 1.0;
205 double pol2 = ((v - 2.0) * v + 1.0) * v * v - UNTRENTE; // Bernoulli(4,v)
206 double temp = C1 * (pol1 - pol2) + C2 * (7.0 * pol1 - 2.0 * pol2);
207
208 // Bernoulli (6, h) and Bernoulli (6, v)
209 pol1 = (((h - 3.0) * h + 2.5) * h * h - 0.5) * h * h + QUARAN;
210 pol2 = (((v - 3.0) * v + 2.5) * v * v - 0.5) * v * v + QUARAN;
211 temp += C3 * (pol1 - pol2);
212 sum -= temp;
213 }
214
215 double disc = sum / n;
216 if (disc < 0.0)
217 return -1.0;
218 return Math.sqrt(disc);
219 }
220
221}
DiscShiftBaker1Lattice(int n, int s, double[] gamma)
The number of points is , the dimension , and the.
double compute(double[][] points, int n, int s, double[] gamma)
Computes the discrepancy ( shiftBaker1lat ) for the -dimensional points of lattice points,...
DiscShiftBaker1Lattice(double[][] points, int n, int s, double[] gamma)
Constructor with the points points[i] in dimensions, with weights gamma[r-1].
double compute(double[] T, int n)
Computes the discrepancy ( shiftBaker1latdim1 ) with weight for the 1-dimensional lattice of points...
double compute(double[][] points, int n, int s)
Computes the discrepancy ( shiftBaker1lat ) for the -dimensional points of lattice points,...
double compute(double[] T, int n, double gamma)
Computes the discrepancy ( shiftBaker1latdim1 ) for the 1-dimensional lattice of points ,...
DiscShiftBaker1Lattice(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions, and with all weights .
DiscShiftBaker1Lattice(Rank1Lattice set)
Constructor with the point set set.
DiscShiftBaker1(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions, with all the weights .
double compute()
Computes the discrepancy of all the points in maximal dimension (dimension of the points).
This class implements point sets specified by integration lattices of rank 1.