SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
Palpha.java
1/*
2 * Class: Palpha
3 * Description: computes the P_alpha figure of merit for a lattice
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 Richard Simard
9 * @since January 2009
10
11 * SSJ is free software: you can redistribute it and/or modify it under
12 * the terms of the GNU General Public License (GPL) as published by the
13 * Free Software Foundation, either version 3 of the License, or
14 * any later version.
15
16 * SSJ is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20
21 * A copy of the GNU General Public License is available at
22 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
23 */
24package umontreal.ssj.discrepancy;
25
26import umontreal.ssj.hups.Rank1Lattice;
27import umontreal.ssj.util.Num;
28import umontreal.ssj.util.PrintfFormat;
29
71public class Palpha extends Discrepancy {
72 // J'utilise les gamma de la classe mère pour beta[]
73 private double[] C; // beta * factors
74 private int alpha;
75
76 private void initFactor(int s, double[] Beta, int alpha) {
77 C = new double[s];
78 for (int j = 1; j <= s; j++)
79 C[j - 1] = Math.pow(2.0 * Math.PI * Beta[j], (double) alpha) / Num.factorial(alpha);
80 }
81
82 private void initA(int s, double[] bet, int alp) {
83 if (null == bet) {
84 setONES(s);
85 gamma = ONES;
86 } else
87 gamma = bet;
88 alpha = alp;
89 }
90
101 public Palpha(double[][] points, int n, int s, double[] beta, int alpha) {
102 super(points, n, s, beta);
103 initA(s, beta, alpha);
104 }
105
110 public Palpha(double[][] points, int n, int s, int alpha) {
111 super(points, n, s);
112 initA(s, null, alpha);
113 }
114
122 public Palpha(int n, int s, double[] beta, int alpha) {
123 super(n, s, beta);
124 initA(s, beta, alpha);
125 }
126
132 public Palpha(int alpha) {
133 this.alpha = alpha;
134 }
135
142 public Palpha(Rank1Lattice set, double[] beta, int alpha) {
143 super(set);
144 initA(set.getDimension(), beta, alpha);
145 }
146
152 public double compute(double[][] points, int n, int s) {
153 return compute(points, n, s, null, alpha);
154 }
155
161 public double compute(double[][] points, int n, int s, double[] beta) {
162 return compute(points, n, s, beta, alpha);
163 }
164
172 public double compute(double[][] points, int n, int s, int alpha) {
173 return compute(points, n, s, null, alpha);
174 }
175
182 public double compute(double[][] points, int n, int s, double[] beta, int alpha) {
183 initA(s, beta, alpha);
184 initFactor(s, gamma, alpha);
185
186 switch (alpha) {
187 case 2:
188 return calcPalpha2(points, n, s, gamma);
189 case 4:
190 return calcPalpha4(points, n, s, gamma);
191 case 6:
192 return calcPalpha6(points, n, s, gamma);
193 case 8:
194 return calcPalpha8(points, n, s, gamma);
195 default:
196 throw new IllegalArgumentException("alpha must be one of {2, 4, 6, 8}");
197 }
198 }
199
204 private double calcPalpha2(double[][] points, int N, int s, double[] beta) {
205 double sum = 0.0;
206 for (int i = 0; i < N; ++i) {
207 double prod = 1.0;
208 for (int j = 0; j < s; ++j) {
209 double u = Points[i][j];
210 prod *= 1.0 + C[j] * (u * (u - 1.0) + UNSIX);
211 }
212 sum += prod;
213 }
214 sum /= N;
215 return beta[0] * (sum - 1.0);
216 }
217
222 private double calcPalpha4(double[][] points, int N, int s, double[] beta) {
223 double sum = 0.0;
224 for (int i = 0; i < N; ++i) {
225 double prod = 1.0;
226 for (int j = 0; j < s; ++j) {
227 double u = Points[i][j];
228 prod *= 1.0 - C[j] * (((u - 2.0) * u + 1.0) * u * u - UNTRENTE);
229 }
230 sum += prod;
231 }
232 sum /= N;
233 return beta[0] * (sum - 1.0);
234 }
235
240 private double calcPalpha6(double[][] points, int N, int s, double[] beta) {
241 double sum = 0.0;
242 for (int i = 0; i < N; ++i) {
243 double prod = 1.0;
244 for (int j = 0; j < s; ++j) {
245 double u = Points[i][j];
246 prod *= 1.0 + C[j] * ((((u - 3.0) * u + 2.5) * u * u - 0.5) * u * u + QUARAN);
247 }
248 sum += prod;
249 }
250 sum /= N;
251 return beta[0] * (sum - 1.0);
252 }
253
258 private double calcPalpha8(double[][] points, int N, int s, double[] beta) {
259 double sum = 0.0;
260 for (int i = 0; i < N; ++i) {
261 double prod = 1.0;
262 for (int j = 0; j < s; ++j) {
263 double u = Points[i][j];
264 prod *= 1.0 - C[j] * (((((u - 4.0) * u + QTIERS) * u * u - STIERS) * u * u + DTIERS) * u * u - UNTRENTE);
265 }
266 sum += prod;
267 }
268 sum /= N;
269 return beta[0] * (sum - 1.0);
270 }
271
272 public String toString() {
273 StringBuffer sb = new StringBuffer(getName() + ":" + PrintfFormat.NEWLINE);
274 sb.append("n = " + numPoints + ", dim = " + dim + PrintfFormat.NEWLINE);
275 sb.append("gamma = [");
276 appendGamma(sb, gamma, dim + 1);
277 sb.append(" ]" + PrintfFormat.NEWLINE);
278 sb.append("alpha = " + alpha + PrintfFormat.NEWLINE);
279 return sb.toString();
280 }
281
286 public void setBeta(double[] beta) {
287 gamma = beta;
288 }
289
290}
int getDimension()
Returns the dimension of the points .
String getName()
Returns the name of the Discrepancy.
Discrepancy(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions.
double compute()
Computes the discrepancy of all the points in maximal dimension (dimension of the points).
double compute(double[][] points, int n, int s, double[] beta)
Computes the discrepancy ( shift1lat ) for the -dimensional points of lattice points,...
Definition Palpha.java:161
double compute(double[][] points, int n, int s, int alpha)
Computes the discrepancy ( shift1lat ) for the -dimensional points of lattice points,...
Definition Palpha.java:172
Palpha(int n, int s, double[] beta, int alpha)
Constructor with points in dimensions and with alpha .
Definition Palpha.java:122
String toString()
Returns the parameters of this class.
Definition Palpha.java:272
void setBeta(double[] beta)
Sets the values of , where is the dimension of the points.
Definition Palpha.java:286
double compute(double[][] points, int n, int s)
Computes the discrepancy ( shift1lat ) for the -dimensional points of lattice points,...
Definition Palpha.java:152
Palpha(double[][] points, int n, int s, double[] beta, int alpha)
Constructor with points in dimensions and with alpha .
Definition Palpha.java:101
Palpha(Rank1Lattice set, double[] beta, int alpha)
Constructor with the lattice set with weights beta[j] and parameter alpha .
Definition Palpha.java:142
Palpha(int alpha)
Constructor with parameter alpha .
Definition Palpha.java:132
double compute(double[][] points, int n, int s, double[] beta, int alpha)
Computes the discrepancy ( shift1lat ) for the -dimensional points of lattice points,...
Definition Palpha.java:182
Palpha(double[][] points, int n, int s, int alpha)
Constructor with all (see eq.
Definition Palpha.java:110
This class implements point sets specified by integration lattices of rank 1.
This class provides various constants and methods to compute numerical quantities such as factorials,...
Definition Num.java:35
static double factorial(int n)
Returns the value of .
Definition Num.java:296
This class acts like a StringBuffer which defines new types of append methods.
static final String NEWLINE
End-of-line symbol or line separator.