SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscL2Symmetric.java
1/*
2 * Class: DiscL2Symmetric
3 * Description: computes the L_2 symmetric 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
55public class DiscL2Symmetric extends Discrepancy {
56
57 public double compute(double[][] points, int n, int s, double[] gamma) {
58 return compute(points, n, s);
59 }
60
67 public DiscL2Symmetric(double[][] points, int n, int s) {
68 super(points, n, s);
69 }
70
75 public DiscL2Symmetric(int n, int s) {
76 super(null, n, s);
77 }
78
84 super(set);
85 }
86
91 public DiscL2Symmetric() {
92 super();
93 }
94
100 public double compute(double[][] points, int n, int s) {
101 double sum = 0.0;
102 for (int i = 0; i < n; ++i) {
103 double prod = 1.0;
104 for (int j = 0; j < s; ++j) {
105 double u = 0.5 - points[i][j];
106 prod *= 1.5 - 2.0 * u * u;
107 }
108 sum += prod;
109 }
110 double disc = -2.0 * sum / n;
111
112 sum = n;
113 double sum2 = 0.0;
114 for (int i = 0; i < n - 1; ++i) {
115 for (int j = i + 1; j < n; ++j) {
116 double prod = 1.0;
117 for (int k = 0; k < s; ++k)
118 prod *= 1.0 - Math.abs(points[i][k] - points[j][k]);
119 sum2 += prod;
120 }
121 }
122
123 disc += (sum + 2.0 * sum2) * Math.pow(2.0, s) / ((long) n * n);
124 disc += Math.pow(4.0 / 3.0, s);
125 if (disc < 0.0)
126 return -1.0;
127 return Math.sqrt(disc);
128 }
129
137 public double compute(double[] T, int n) {
138 double sum = 0.0;
139 for (int i = 0; i < n; ++i)
140 sum += T[i] * (1.0 - T[i]);
141 double disc = -4.0 * sum / n;
142
143 sum = 0.0;
144 for (int i = 0; i < n - 1; ++i) {
145 for (int j = i + 1; j < n; ++j)
146 sum += Math.abs(T[i] - T[j]);
147 }
148
149 disc -= 4.0 * sum / ((long) n * n);
150 disc += 4.0 / 3.0;
151 if (disc < 0.0)
152 return 0.0;
153 return Math.sqrt(disc);
154 }
155
156}
double compute(double[] T, int n)
Computes the -symmetric discrepancy for the set of 1-dimensional points.
DiscL2Symmetric(int n, int s)
Constructor with points in dimension .
double compute(double[][] points, int n, int s)
Computes the -symmetric discrepancy for the set of -dimensional points points, using formula ( sym )...
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.
DiscL2Symmetric(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions.
DiscL2Symmetric(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