SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscShift1.java
1/*
2 * Class: DiscShift1
3 * Description: computes a discrepancy for the randomly shifted points of a set
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;
27import umontreal.ssj.util.Num;
28
68public class DiscShift1 extends Discrepancy {
69
70 static protected void setC(double[] C1, double[] gam, int s) {
71 for (int i = 0; i < s; i++)
72 C1[i] = gam[i] * gam[i];
73 }
74
80 public DiscShift1(double[][] points, int n, int s) {
81 super(points, n, s);
82 }
83
91 public DiscShift1(double[][] points, int n, int s, double[] gamma) {
92 super(points, n, s, gamma);
93 }
94
101 public DiscShift1(int n, int s, double[] gamma) {
102 super(n, s, gamma);
103 }
104
109 public DiscShift1(PointSet set) {
110 super(set);
111 }
112
117 public DiscShift1() {
118 }
119
125 public double compute(double[][] points, int n, int s) {
126 setONES(s);
127 return compute(points, n, s, ONES);
128 }
129
134 public double compute(double[][] points, int n, int s, double[] gamma) {
135 double[] C1 = new double[s]; // gamma_r^2
136 setC(C1, gamma, s);
137
138 double pol1 = UNSIX; // BernoulliPoly(2, 0);
139 double prod = 1.0;
140 for (int r = 0; r < s; ++r)
141 prod *= (1.0 + C1[r] * pol1);
142 double disc = prod / n;
143
144 double sum = 0.0;
145 for (int i = 0; i < n - 1; ++i) {
146 for (int j = i + 1; j < n; ++j) {
147 prod = 1.0;
148 for (int r = 0; r < s; ++r) {
149 double u = points[i][r] - points[j][r];
150 if (u < 0.0)
151 u += 1.0;
152 pol1 = u * (u - 1.0) + UNSIX; // Bernoulli(2, u)
153 prod *= 1.0 + C1[r] * pol1;
154 }
155 sum += prod;
156 }
157 }
158
159 disc += 2.0 * sum / ((long) n * n) - 1.0;
160 if (disc < 0.0)
161 return -1.0;
162 return Math.sqrt(disc);
163 }
164
169 public double compute(double[] T, int n) {
170 double pol1 = UNSIX; // BernoulliPoly(2, 0);
171 double disc = pol1 / n;
172
173 double sum = 0.0;
174 for (int i = 0; i < n - 1; ++i) {
175 for (int j = i + 1; j < n; ++j) {
176 double h = T[i] - T[j];
177 if (h < 0.0)
178 h += 1.0;
179 pol1 = h * (h - 1.0) + UNSIX; // Bernoulli(2, h)
180 sum += pol1;
181 }
182 }
183
184 disc += 2.0 * sum / ((long) n * n);
185 if (disc < 0.0)
186 return -1.0;
187 return Math.sqrt(disc);
188 }
189
190}
double compute(double[][] points, int n, int s, double[] gamma)
Computes the discrepancy ( shift1 ) in dimension with gamma[r-1].
DiscShift1(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions and with all weights .
DiscShift1(int n, int s, double[] gamma)
The number of points is , the dimension , and the.
double compute(double[] T, int n)
Computes the discrepancy ( shift1dim1 ) for the 1-dimensional set of points .
double compute(double[][] points, int n, int s)
Computes the discrepancy ( shift1 ) for the first points of set points in dimension .
DiscShift1(double[][] points, int n, int s, double[] gamma)
Constructor with the points points[i] in dimensions, and with the weights gamma[r-1],...
DiscShift1(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