SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscL2Unanchored.java
1/*
2 * Class: DiscL2Unanchored
3 * Description: computes the L_2 unanchored 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
61public class DiscL2Unanchored extends Discrepancy {
62
63 public double compute(double[][] points, int n, int s, double[] gamma) {
64 return compute(points, n, s);
65 }
66
73 public DiscL2Unanchored(double[][] points, int n, int s) {
74 super(points, n, s);
75 }
76
81 public DiscL2Unanchored(int n, int s) {
82 super(null, n, s);
83 }
84
90 super(set);
91 }
92
98 super();
99 }
100
106 public double compute(double[][] points, int n, int s) {
107 double sum = 0.0;
108 for (int i = 0; i < n; ++i) {
109 double prod = 1.0;
110 for (int k = 0; k < s; ++k)
111 prod *= points[i][k] * (1.0 - points[i][k]);
112 sum += prod;
113 }
114 double disc = sum / n * (1.0 / n - Math.pow(0.5, (double) (s - 1)));
115
116 sum = 0.0;
117 for (int i = 0; i < n - 1; ++i) {
118 for (int j = i + 1; j < n; ++j) {
119 double prod = 1.0;
120 for (int k = 0; k < s; ++k)
121 prod *= Math.min(points[i][k], points[j][k]) - points[i][k] * points[j][k];
122 sum += prod;
123 }
124 }
125
126 disc += 2.0 * sum / ((long) n * n);
127 disc += Math.pow(1.0 / 12.0, s);
128 if (disc < 0.0)
129 return -1.0;
130 return Math.sqrt(disc);
131 }
132
140 public double compute(double[] T, int n) {
141 double sum = 0.0;
142 for (int i = 0; i < n; ++i)
143 sum += T[i] * (1.0 - T[i]);
144 double disc = -(1.0 - 1.0 / n) * sum / n;
145
146 double sum2 = 0.0;
147 for (int i = 0; i < n - 1; ++i) {
148 for (int j = i + 1; j < n; ++j)
149 sum2 += Math.min(T[i], T[j]) - T[i] * T[j];
150 }
151
152 disc += 2.0 * sum2 / ((long) n * n);
153 disc += 1.0 / 12.0;
154 if (disc < 0.0)
155 return -1.0;
156 return Math.sqrt(disc);
157 }
158
159}
double compute(double[][] points, int n, int s)
Computes the -unanchored discrepancy ( disc.unan ) for the set of -dimensional points points.
DiscL2Unanchored(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions.
DiscL2Unanchored(PointSet set)
Constructor with the point set set.
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.
DiscL2Unanchored(int n, int s)
Constructor with points in dimension .
double compute(double[] T, int n)
Computes the -unanchored discrepancy for the 1-dimensional set of points.
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