24package umontreal.ssj.discrepancy;
26import umontreal.ssj.hups.PointSet;
27import umontreal.ssj.util.Num;
71 protected static double[] setC(
double gam) {
73 double[] C =
new double[2];
81 protected static void setC(
double[] C1,
double[] C2,
double[] gam,
int s) {
82 for (
int i = 0; i < s; i++) {
83 double v = gam[i] * gam[i];
106 public DiscShift2(
double[][] points,
int n,
int s,
double[] gamma) {
107 super(points, n, s, gamma);
140 public double compute(
double[][] points,
int n,
int s) {
142 return compute(points, n, s, ONES);
150 public double compute(
double[][] points,
int n,
int s,
double[] gamma) {
151 double[] C1 =
new double[s];
152 double[] C2 =
new double[s];
153 setC(C1, C2, gamma, s);
156 double pol2 = -UNTRENTE;
158 for (
int r = 0; r < s; ++r)
159 prod *= (1.0 + C1[r] * pol1 - C2[r] * pol2);
160 double disc = prod / n;
163 for (
int i = 0; i < n - 1; ++i) {
164 for (
int j = i + 1; j < n; ++j) {
166 for (
int r = 0; r < s; ++r) {
167 double u = points[i][r] - points[j][r];
170 pol1 = u * (u - 1.0) + UNSIX;
171 pol2 = ((u - 2.0) * u + 1.0) * u * u - UNTRENTE;
172 prod *= 1.0 + C1[r] * pol1 - C2[r] * pol2;
178 disc += 2.0 * sum / ((long) n * n) - 1.0;
181 return Math.sqrt(disc);
198 public double compute(
double[] T,
int n,
double gamma) {
200 double pol2 = -UNTRENTE;
201 double[] C = setC(gamma);
204 double disc = (C1 * pol1 - C2 * pol2) / n;
207 for (
int i = 0; i < n - 1; ++i) {
208 for (
int j = i + 1; j < n; ++j) {
209 double u = T[i] - T[j];
212 pol1 = u * (u - 1.0) + UNSIX;
213 pol2 = ((u - 2.0) * u + 1.0) * u * u - UNTRENTE;
214 sum += (C1 * pol1 - C2 * pol2);
218 disc += 2.0 * sum / ((long) n * n);
221 return Math.sqrt(disc);
double compute(double[] T, int n, double gamma)
Computes the discrepancy ( shift2dim1 ) for the first points of in 1 dimension, with weight gamma.
DiscShift2(PointSet set)
Constructor with the point set set.
double compute(double[] T, int n)
Computes the discrepancy ( shift2dim1 ) for the first points of in 1 dimension, with weight .
DiscShift2()
Empty constructor.
double compute(double[][] points, int n, int s)
Computes the discrepancy ( shift2 ) for the first points of set points in dimension .
double compute(double[][] points, int n, int s, double[] gamma)
Computes the discrepancy ( shift2 ) for the first points of set points in dimension and with weight...
DiscShift2(double[][] points, int n, int s)
Constructor with the points points[i] in dimension , with all weights .
DiscShift2(int n, int s, double[] gamma)
The number of points is , the dimension , and the.
DiscShift2(double[][] points, int n, int s, double[] gamma)
Constructor with the points points[i] in dimension , with the weights gamma[j-1],...
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.