SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
DiscShift2Lattice.java
1/*
2 * Class: DiscShift2Lattice
3 * Description: computes a discrepancy for the randomly shifted points of a
4 lattice
5 * Environment: Java
6 * Software: SSJ
7 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
8 * Organization: DIRO, Universite de Montreal
9 * @author Richard Simard
10 * @since January 2009
11
12 * SSJ is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU General Public License (GPL) as published by the
14 * Free Software Foundation, either version 3 of the License, or
15 * any later version.
16
17 * SSJ is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21
22 * A copy of the GNU General Public License is available at
23 <a href="http://www.gnu.org/licenses">GPL licence site</a>.
24 */
25package umontreal.ssj.discrepancy;
26
27import umontreal.ssj.hups.Rank1Lattice;
28
50public class DiscShift2Lattice extends DiscShift2 {
51
57 public DiscShift2Lattice(double[][] points, int n, int s) {
58 super(points, n, s);
59 }
60
66 public DiscShift2Lattice(double[][] points, int n, int s, double[] gamma) {
67 super(points, n, s, gamma);
68 }
69
76 public DiscShift2Lattice(int n, int s, double[] gamma) {
77 super(n, s, gamma);
78 }
79
85 super(set);
86 }
87
93 }
94
100 public double compute(double[][] points, int n, int s) {
101 setONES(s);
102 return compute(points, n, s, ONES);
103 }
104
109 public double compute(double[][] points, int n, int s, double[] gamma) {
110 double[] C1 = new double[s];
111 double[] C2 = new double[s];
112 setC(C1, C2, gamma, s);
113
114 double sum = 0.0;
115 for (int i = 0; i < n; ++i) {
116 double prod = 1.0;
117 for (int r = 0; r < s; ++r) {
118 double u = points[i][r];
119 double pol1 = u * (u - 1.0) + UNSIX; // Bernoulli(2, u)
120 double pol2 = ((u - 2.0) * u + 1.0) * u * u - UNTRENTE; // Bernoulli(4,h)
121 prod *= 1.0 + C1[r] * pol1 - C2[r] * pol2;
122 }
123 sum += prod;
124 }
125 double disc = sum / n - 1.0;
126 if (disc < 0.0)
127 return -1.0;
128 return Math.sqrt(disc);
129 }
130
137 public double compute(double[] T, int n) {
138 return compute(T, n, 1.);
139 }
140
147 public double compute(double[] T, int n, double gamma) {
148 double[] C = setC(gamma);
149 double C1 = C[0];
150 double C2 = C[1];
151 double pol1;
152 double pol2;
153
154 double sum = 0.0;
155 for (int i = 0; i < n; ++i) {
156 double u = T[i];
157 pol1 = u * (u - 1.0) + UNSIX; // Bernoulli(2, u)
158 pol2 = ((u - 2.0) * u + 1.0) * u * u - UNTRENTE; // Bernoulli(4,h)
159 sum += C1 * pol1 - C2 * pol2;
160 }
161 double disc = sum / n;
162 if (disc <= 0.0)
163 return 0.0;
164 return Math.sqrt(disc);
165 }
166
167}
double compute(double[][] points, int n, int s, double[] gamma)
Computes the discrepancy ( shift2lat ) in dimension with gamma[r-1].
double compute(double[][] points, int n, int s)
Computes the discrepancy ( shift2lat ) for the first -dimensional points of lattice points.
double compute(double[] T, int n, double gamma)
Computes the discrepancy ( shift2dim1lat ) with weight gamma for the 1-dimensional lattice of point...
DiscShift2Lattice(Rank1Lattice set)
Constructor with the lattice set.
DiscShift2Lattice(int n, int s, double[] gamma)
The number of points is , the dimension , and the.
DiscShift2Lattice(double[][] points, int n, int s, double[] gamma)
Constructor with the points points[i] in dimension with the weights gamma[r-1],...
DiscShift2Lattice(double[][] points, int n, int s)
Constructor with the points points[i] in dimension with all weights .
double compute(double[] T, int n)
Computes the discrepancy ( shift2dim1lat ) with weight for the 1-dimensional lattice of points .
DiscShift2(double[][] points, int n, int s)
Constructor with the points points[i] in dimension , with all weights .
double compute()
Computes the discrepancy of all the points in maximal dimension (dimension of the points).
This class implements point sets specified by integration lattices of rank 1.