use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class InstanceRankNormalizationTest method defaultParameters.
/**
* Test with default parameters.
*/
@Test
public void defaultParameters() {
String filename = UNITTEST + "normalization-test-1.csv";
InstanceRankNormalization<DoubleVector> filter = new ELKIBuilder<>(InstanceRankNormalization.class).build();
MultipleObjectsBundle bundle = readBundle(filename, filter);
int dim = getFieldDimensionality(bundle, 0, TypeUtil.NUMBER_VECTOR_FIELD);
// Verify that, in each row, the min value is 0 and the max value 1.
DoubleMinMax mms = new DoubleMinMax();
for (int row = 0; row < bundle.dataLength(); row++) {
mms.reset();
DoubleVector d = get(bundle, row, 0, DoubleVector.class);
for (int col = 0; col < dim; col++) {
mms.put(d.doubleValue(col));
}
assertEquals("Min value is not 0", 0., mms.getMin(), 0);
assertEquals("Max value is not 1", 1., mms.getMax(), 0);
}
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class Log1PlusNormalizationTest method defaultParameters.
/**
* Test with default parameters.
*/
@Test
public void defaultParameters() {
String filename = UNITTEST + "normalization-test-1.csv";
InstanceMinMaxNormalization<DoubleVector> minMaxFilter = new ELKIBuilder<>(InstanceMinMaxNormalization.class).build();
Log1PlusNormalization<DoubleVector> log1plusFilter = new ELKIBuilder<>(Log1PlusNormalization.class).build();
MultipleObjectsBundle bundle = readBundle(filename, minMaxFilter, log1plusFilter);
int dim = getFieldDimensionality(bundle, 0, TypeUtil.NUMBER_VECTOR_FIELD);
// We verify that minimum and maximum values in each row are 0 and 1:
DoubleMinMax mms = new DoubleMinMax();
for (int row = 0; row < bundle.dataLength(); row++) {
mms.reset();
DoubleVector d = get(bundle, row, 0, DoubleVector.class);
for (int col = 0; col < dim; col++) {
final double val = d.doubleValue(col);
if (val > Double.NEGATIVE_INFINITY && val < Double.POSITIVE_INFINITY) {
mms.put(val);
}
}
assertEquals("Minimum not expected", 0., mms.getMin(), 1e-15);
assertEquals("Maximum not expected", 1., mms.getMax(), 1e-15);
}
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class SweepHullDelaunay2D method getHull.
/**
* Get the convex hull only.
*
* Note: if you also want the Delaunay Triangulation, you should get that
* first!
*
* @return Convex hull
*/
public Polygon getHull() {
if (hull == null) {
run(true);
}
DoubleMinMax minmaxX = new DoubleMinMax();
DoubleMinMax minmaxY = new DoubleMinMax();
List<double[]> hullp = new ArrayList<>(hull.size());
for (IntIntPair pair : hull) {
double[] v = points.get(pair.first);
hullp.add(v);
minmaxX.put(v[0]);
minmaxY.put(v[1]);
}
return new Polygon(hullp, minmaxX.getMin(), minmaxX.getMax(), minmaxY.getMin(), minmaxY.getMax());
}
use of de.lmu.ifi.dbs.elki.math.DoubleMinMax in project elki by elki-project.
the class AttributeWiseMinMaxNormalizationTest method defaultParameters.
/**
* Test with default parameters.
*/
@Test
public void defaultParameters() {
String filename = UNITTEST + "normalization-test-1.csv";
AttributeWiseMinMaxNormalization<DoubleVector> filter = new ELKIBuilder<AttributeWiseMinMaxNormalization<DoubleVector>>(AttributeWiseMinMaxNormalization.class).build();
MultipleObjectsBundle bundle = readBundle(filename, filter);
int dim = getFieldDimensionality(bundle, 0, TypeUtil.NUMBER_VECTOR_FIELD);
// We verify that minimum and maximum values in each column are 0 and 1:
DoubleMinMax[] mms = DoubleMinMax.newArray(dim);
for (int row = 0; row < bundle.dataLength(); row++) {
DoubleVector d = get(bundle, row, 0, DoubleVector.class);
for (int col = 0; col < dim; col++) {
final double val = d.doubleValue(col);
if (val > Double.NEGATIVE_INFINITY && val < Double.POSITIVE_INFINITY) {
mms[col].put(val);
}
}
}
for (int col = 0; col < dim; col++) {
assertEquals("Minimum not as expected", 0., mms[col].getMin(), 0.);
assertEquals("Maximum not as expected", 1., mms[col].getMax(), 0.);
}
}
Aggregations