24package umontreal.ssj.discrepancy;
26import umontreal.ssj.hups.*;
27import cern.colt.list.DoubleArrayList;
28import umontreal.ssj.util.PrintfFormat;
37 protected static double[] ONES = { 1 };
38 protected double[] gamma;
39 protected double[][] Points;
41 protected int numPoints;
45 static final double UNSIX = 1.0 / 6.0;
46 static final double QUARAN = 1.0 / 42.0;
47 static final double UNTRENTE = 1.0 / 30.0;
48 static final double DTIERS = 2.0 / 3.0;
49 static final double STIERS = 7.0 / 3.0;
50 static final double QTIERS = 14.0 / 3.0;
52 static protected void setONES(
int s) {
55 ONES =
new double[s + 1];
56 for (
int i = 0; i <= s; i++)
60 protected void appendGamma(StringBuffer sb,
double[] gamma,
int s) {
63 for (
int j = 0; j < s; ++j)
64 sb.append(
" " + gamma[j]);
68 private void initD(
double[][] points,
int n,
int s,
double[] gamma) {
87 initD(points, n, s,
null);
99 public Discrepancy(
double[][] points,
int n,
int s,
double[] gamma) {
100 initD(points, n, s, gamma);
110 initD(
null, n, s, gamma);
118 numPoints =
set.getNumPoints();
119 dim =
set.getDimension();
121 initD(Points, numPoints, dim,
null);
136 return compute(Points, numPoints, dim, gamma);
143 return compute(Points, numPoints, s, gamma);
150 public double compute(
double[][] points,
int n,
int s,
double[] gamma) {
158 public abstract double compute(
double[][] points,
int n,
int s);
166 return compute(points, points.length, points[0].length, gamma);
176 double[][] p =
new double[n][1];
177 for (
int i = 0; i < n; ++i)
187 return compute(T, T.length, gamma[0]);
194 public double compute(
double[] T,
int n,
double gamma) {
203 int n =
set.getNumPoints();
204 int dim =
set.getDimension();
206 double[][] points =
new double[n][dim];
208 for (
int i = 0; i < n; ++i) {
211 return compute(points, n, dim, gamma);
213 double[] points =
new double[n];
215 for (
int i = 0; i < n; ++i) {
219 return compute(points, n, gamma[0]);
228 int dim =
set.getDimension();
251 public void setPoints(
double[][] points,
int n,
int s) {
252 initD(points, n, s,
null);
260 setPoints(points, points.length, points[0].length);
284 int n =
set.getNumPoints();
285 int dim =
set.getDimension();
287 double[][] points =
new double[n][dim];
289 for (
int i = 0; i < n; ++i)
294 double[][] po1 =
new double[n][1];
296 for (
int i = 0; i < n; ++i) {
308 public static DoubleArrayList
sort(
double[] T,
int n) {
309 DoubleArrayList sortedU =
new DoubleArrayList(T);
310 sortedU.sortFromTo(0, n - 1);
320 sb.append(
"gamma = [");
321 appendGamma(sb, gamma, dim);
323 return sb.toString();
331 if (Points !=
null) {
332 for (
int i = 0; i < Points.length; ++i) {
333 sb.append(
" [ " + Points[i][0]);
334 for (
int j = 1; j < Points[0].length; ++j)
335 sb.append(
", " + Points[i][j]);
340 return sb.toString();
347 return getClass().getSimpleName();
double compute(PointSet set, double[] gamma)
Computes the discrepancy of all the points in set in the same dimension as the point set and with wei...
double compute(double[] T)
Computes the discrepancy of all the points of T in 1 dimension.
int getDimension()
Returns the dimension of the points .
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.
String formatPoints()
Returns all the points of this class.
double compute(int s)
Computes the discrepancy of all the points in dimension .
Discrepancy(int n, int s, double[] gamma)
The number of points is , the dimension , and the.
double compute(double[][] points)
Computes the discrepancy of all the points of points in maximum dimension.
void setPoints(double[][] points)
Sets the points to points.
double compute(double[] T, int n)
Computes the discrepancy of the first n points of T in 1 dimension.
String getName()
Returns the name of the Discrepancy.
String toString()
Returns the parameters of this class.
Discrepancy(double[][] points, int n, int s, double[] gamma)
Constructor with the points points[i] in dimensions and the weight factors gamma[ ],...
Discrepancy(PointSet set)
Constructor with the point set set.
double compute(PointSet set)
Computes the discrepancy of all the points in set in the same dimension as the point set.
static double[][] toArray(PointSet set)
Returns all the points ( -dimensional) of.
Discrepancy(double[][] points, int n, int s)
Constructor with the points points[i] in dimensions.
int getNumPoints()
Returns the number of points .
static DoubleArrayList sort(double[] T, int n)
Sorts the first points of .
double compute(double[] T, int n, double gamma)
Computes the discrepancy of the first n points of T in 1 dimension with weight gamma.
Discrepancy()
Empty constructor.
void setGamma(double[] gam, int s)
Sets the weight factors to gam for each dimension up to .
double compute()
Computes the discrepancy of all the points in maximal dimension (dimension of the points).
abstract double compute(double[][] points, int n, int s)
Computes the discrepancy of the first n points of points in dimension s with weights .
void setPoints(double[][] points, int n, int s)
Sets the points to points and the dimension to .
double[] getGamma()
Returns the weight factors gamma for each dimension up to .
This abstract class represents a general point set.
This is the interface for iterators that permit one to go through the points of a PointSet and the su...
int nextPoint(double[] p, int fromDim, int d)
Returns in p the next d coordinates of the current point, starting at coordinate fromDim (i....
int resetToNextPoint()
Increases the current point index by 1 and returns its new value.
double nextCoordinate()
Returns the current coordinate and advances to the next one.