SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscL2Star.java
1/*
2 * Class: DiscL2Star
3 * Description: computes the traditional 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
75public class DiscL2Star extends Discrepancy {
76
77 public double compute(double[][] points, int n, int s, double[] gamma) {
78 return compute(points, n, s);
79 }
80
87 public DiscL2Star(double[][] points, int n, int s) {
88 super(points, n, s);
89 }
90
95 public DiscL2Star(int n, int s) {
96 super(null, n, s);
97 }
98
103 public DiscL2Star(PointSet set) {
104 super(set);
105 }
106
111 public DiscL2Star() {
112 super();
113 }
114
120 public double compute(double[][] points, int n, int s) {
121 double sum = 0.0;
122 for (int i = 0; i < n; ++i) {
123 double prod = 1.0;
124 for (int j = 0; j < s; ++j) {
125 double u = points[i][j];
126 prod *= (1.0 - u) * (1.0 + u);
127 }
128 sum += prod;
129 }
130 double disc = -Math.pow(0.5, (double) (s - 1)) * sum / n;
131
132 sum = 0.0;
133 for (int i = 0; i < n; ++i) {
134 double prod = 1.0;
135 for (int j = 0; j < s; ++j)
136 prod *= 1.0 - points[i][j];
137 sum += prod;
138 }
139
140 double sum2 = 0.0;
141 for (int i = 0; i < n - 1; ++i) {
142 for (int j = i + 1; j < n; ++j) {
143 double prod = 1.0;
144 for (int k = 0; k < s; ++k)
145 prod *= 1.0 - Math.max(points[i][k], points[j][k]);
146 sum2 += prod;
147 }
148 }
149
150 disc += (sum + 2.0 * sum2) / ((long) n * n);
151 disc += Math.pow(1.0 / 3.0, s);
152 if (disc < 0.0)
153 return 0.0;
154 return Math.sqrt(disc);
155 }
156
165 public double compute(double[] T, int n) {
166 double W2 = 0.0;
167 double v;
168 for (int i = 0; i < n; i++) {
169 v = T[i] - (i + 0.5) / n;
170 W2 += v * v;
171 }
172 W2 += 1.0 / (12.0 * n);
173
174 return Math.sqrt(W2 / n);
175 }
176
177}
DiscL2Star(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 traditional -star discrepancy for the set of 1-dimensional points.
DiscL2Star(double[][] points, int n, int s)
Constructor with the points points[i] in dimension.
double compute(double[][] points, int n, int s)
Computes the traditional -star discrepancy ( discstar ) for the first points of points,...
DiscL2Star(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