SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscL2Hickernell.java
1/*
2 * Class: DiscL2Hickernell
3 * Description: computes the Hickernell L_2 star discrepancy
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.PointSet;
27
65public class DiscL2Hickernell extends Discrepancy {
66
67 public double compute(double[][] points, int n, int s, double[] gamma) {
68 return compute(points, n, s);
69 }
70
77 public DiscL2Hickernell(double[][] points, int n, int s) {
78 super(points, n, s);
79 }
80
85 public DiscL2Hickernell(int n, int s) {
86 super(null, n, s);
87 }
88
94 super(set);
95 }
96
102 super();
103 }
104
114 public double compute(double[][] points, int n, int s) {
115 final int N = n;
116 final double RAC3 = 1.73205080756887729352; // sqrt(3)
117 double sum = 0.0;
118 for (int i = 0; i < N; ++i) {
119 double prod = 1.0;
120 for (int j = 0; j < s; ++j) {
121 double u = points[i][j];
122 prod *= (RAC3 - u) * (RAC3 + u);
123 }
124 sum += prod;
125 }
126 double disc = -Math.pow(0.5, (double) (s - 1)) * sum / N;
127
128 sum = 0.0;
129 for (int i = 0; i < N; ++i) {
130 double prod = 1.0;
131 for (int j = 0; j < s; ++j)
132 prod *= 2.0 - points[i][j];
133 sum += prod;
134 }
135
136 double sum2 = 0.0;
137 for (int i = 0; i < N - 1; ++i) {
138 for (int j = i + 1; j < N; ++j) {
139 double prod = 1.0;
140 for (int k = 0; k < s; ++k)
141 prod *= 2.0 - Math.max(points[i][k], points[j][k]);
142 sum2 += prod;
143 }
144 }
145
146 disc += (sum + 2.0 * sum2) / ((long) N * N);
147 disc += Math.pow(4.0 / 3.0, s);
148 if (disc < 0.0)
149 return -1.0;
150 return Math.sqrt(disc);
151 }
152
162 public double compute(double[] T, int n) {
163 // In 1 dimension, L2*Hickernell = L2*
164 double sum = 0.0;
165 for (int i = 0; i < n; ++i)
166 sum += T[i] * T[i];
167 double disc = sum / n;
168
169 sum = 0.0;
170 for (int i = 0; i < n; ++i)
171 sum += T[i];
172
173 double sum2 = 0.0;
174 for (int i = 0; i < n - 1; ++i) {
175 for (int j = i + 1; j < n; ++j)
176 sum2 += Math.max(T[i], T[j]);
177 }
178
179 disc -= (sum + 2.0 * sum2) / ((long) n * n);
180 disc += 1.0 / 3.0;
181 if (disc < 0.0)
182 return -1.0;
183 return Math.sqrt(disc);
184 }
185
186}
DiscL2Hickernell(int n, int s)
Constructor with points in dimension .
double compute(double[][] points, int n, int s, double[] gamma)
Computes the discrepancy of the first n points of points in dimension s with weights gamma.
double compute(double[] T, int n)
Computes the Hickernell.
DiscL2Hickernell(double[][] points, int n, int s)
Constructor with the points points[i] in dimension.
double compute(double[][] points, int n, int s)
Computes the Hickernell.
DiscL2Hickernell(PointSet set)
Constructor with the point set set.
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).
This abstract class represents a general point set.
Definition PointSet.java:99