diff options
author | Erich Schubert <erich@debian.org> | 2012-01-30 21:01:31 +0100 |
---|---|---|
committer | Andrej Shadura <andrewsh@debian.org> | 2019-03-09 22:30:31 +0000 |
commit | e580e42664ca92fbf8792bc39b8d59383db829fe (patch) | |
tree | 787e6b9e9aed85fae4010f860171de1829cb0edb | |
parent | 3a6ca942c89382b33bbc95ad772e4def12109da1 (diff) | |
parent | 89aa1958dbaf9052da0c24706308a2ef8cefa96e (diff) |
Import Debian changes 0.4.1-1
elki (0.4.1-1) unstable; urgency=low
* New upstream bug fix release (a couple of minor fixes)
* Specify encoding UTF-8 for javac (Closes: #642659)
17 files changed, 149 insertions, 48 deletions
diff --git a/debian/changelog b/debian/changelog index 1728b88f..93e85cf2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +elki (0.4.1-1) unstable; urgency=low + + * New upstream bug fix release (a couple of minor fixes) + * Specify encoding UTF-8 for javac (Closes: #642659) + + -- Erich Schubert <erich@debian.org> Mon, 30 Jan 2012 21:01:31 +0100 + elki (0.4.0-1) unstable; urgency=low * New upstream release. (0.4.0 final) diff --git a/debian/patches/build.patch b/debian/patches/build.patch index 9ac8e7e7..9bc8c024 100644 --- a/debian/patches/build.patch +++ b/debian/patches/build.patch @@ -1,17 +1,17 @@ -Index: elki-0.4.0~beta2/build.xml +# Debian build.xml file +Index: elki-0.4.1/build.xml =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 -+++ elki-0.4.0~beta2/build.xml 2011-09-03 01:54:38.000000000 +0200 -@@ -0,0 +1,58 @@ ++++ elki-0.4.1/build.xml 2012-01-30 21:01:27.000000000 +0100 +@@ -0,0 +1,57 @@ +<project name="ELKI" default="dist" basedir="."> + <property name="src" location="src"/> + <property name="build" location="build"/> + <property name="dist" location="dist"/> + <property name="elki" value="de.lmu.ifi.dbs.elki"/> -+ <property name="title" value="ELKI: Environment for DeveLoping KDD-A -+pplications Supported by Index-Structures"/> ++ <property name="title" value="ELKI: Environment for DeveLoping KDD-Applications Supported by Index-Structures"/> + <property name="url" value="http://elki.dbs.ifi.lmu.de/"/> -+ <property name="version" value="0.4.0~beta1"/> ++ <property name="version" value="0.4.1"/> + + <target name="init"> + <!-- Create the build directory structure used by compile --> @@ -20,7 +20,7 @@ Index: elki-0.4.0~beta2/build.xml + + <target name="compile" depends="init"> + <!-- Compile the java code from ${src} into ${build} --> -+ <javac destdir="${build}" includeantruntime="false" deprecation="false" debug="false" optimize="true" source="1.6" target="1.6" debuglevel=""> ++ <javac destdir="${build}" includeantruntime="false" deprecation="false" debug="false" optimize="true" source="1.6" target="1.6" debuglevel="" encoding="UTF-8"> + <compilerarg value="-Xlint:all" /> + <classpath> + <pathelement path="${src}" /> diff --git a/src/de/lmu/ifi/dbs/elki/algorithm/clustering/DeLiClu.java b/src/de/lmu/ifi/dbs/elki/algorithm/clustering/DeLiClu.java index d4d6d20a..ca401ddc 100644 --- a/src/de/lmu/ifi/dbs/elki/algorithm/clustering/DeLiClu.java +++ b/src/de/lmu/ifi/dbs/elki/algorithm/clustering/DeLiClu.java @@ -153,7 +153,7 @@ public class DeLiClu<NV extends NumberVector<NV, ?>, D extends Distance<D>> exte clusterOrder.add(startID, null, distFunction.getDistanceFactory().infiniteDistance()); int numHandled = 1; index.setHandled(startID, relation.get(startID)); - SpatialDirectoryEntry rootEntry = (SpatialDirectoryEntry)index.getRootEntry(); + SpatialDirectoryEntry rootEntry = (SpatialDirectoryEntry) index.getRootEntry(); SpatialObjectPair spatialObjectPair = new SpatialObjectPair(distFunction.getDistanceFactory().nullDistance(), rootEntry, rootEntry, true); heap.add(spatialObjectPair); @@ -217,8 +217,8 @@ public class DeLiClu<NV extends NumberVector<NV, ?>, D extends Distance<D>> exte * @param knns the knn list */ private void expandNodes(DeLiCluTree index, SpatialPrimitiveDistanceFunction<NV, D> distFunction, SpatialObjectPair nodePair, DataStore<KNNList<D>> knns) { - DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry)nodePair.entry1).getPageID()); - DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry)nodePair.entry2).getPageID()); + DeLiCluNode node1 = index.getNode(((SpatialDirectoryEntry) nodePair.entry1).getPageID()); + DeLiCluNode node2 = index.getNode(((SpatialDirectoryEntry) nodePair.entry2).getPageID()); if(node1.isLeaf()) { expandLeafNodes(distFunction, node1, node2, knns); @@ -238,6 +238,9 @@ public class DeLiClu<NV extends NumberVector<NV, ?>, D extends Distance<D>> exte * @param node2 the second node */ private void expandDirNodes(SpatialPrimitiveDistanceFunction<NV, D> distFunction, DeLiCluNode node1, DeLiCluNode node2) { + if(logger.isDebuggingFinest()) { + logger.debugFinest("ExpandDirNodes: " + node1.getPageID() + " + " + node2.getPageID()); + } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); @@ -271,6 +274,9 @@ public class DeLiClu<NV extends NumberVector<NV, ?>, D extends Distance<D>> exte * @param knns the knn list */ private void expandLeafNodes(SpatialPrimitiveDistanceFunction<NV, D> distFunction, DeLiCluNode node1, DeLiCluNode node2, DataStore<KNNList<D>> knns) { + if(logger.isDebuggingFinest()) { + logger.debugFinest("ExpandLeafNodes: " + node1.getPageID() + " + " + node2.getPageID()); + } int numEntries_1 = node1.getNumEntries(); int numEntries_2 = node2.getNumEntries(); @@ -304,7 +310,7 @@ public class DeLiClu<NV extends NumberVector<NV, ?>, D extends Distance<D>> exte * @param knns the knn list */ private void reinsertExpanded(SpatialPrimitiveDistanceFunction<NV, D> distFunction, DeLiCluTree index, List<TreeIndexPathComponent<DeLiCluEntry>> path, DataStore<KNNList<D>> knns) { - SpatialDirectoryEntry rootEntry = (SpatialDirectoryEntry)path.remove(0).getEntry(); + SpatialDirectoryEntry rootEntry = (SpatialDirectoryEntry) path.remove(0).getEntry(); reinsertExpanded(distFunction, index, path, 0, rootEntry, knns); } diff --git a/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNOutlier.java b/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNOutlier.java index e8097518..fa89f954 100644 --- a/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNOutlier.java +++ b/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNOutlier.java @@ -40,6 +40,7 @@ import de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction; import de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance;
import de.lmu.ifi.dbs.elki.logging.Logging;
import de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress;
+import de.lmu.ifi.dbs.elki.math.DoubleMinMax;
import de.lmu.ifi.dbs.elki.database.relation.MaterializedRelation;
import de.lmu.ifi.dbs.elki.result.outlier.BasicOutlierScoreMeta;
import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult;
@@ -113,7 +114,7 @@ public class KNNOutlier<O, D extends NumberDistance<D, ?>> extends AbstractDista }
FiniteProgress progressKNNDistance = logger.isVerbose() ? new FiniteProgress("kNN distance for objects", relation.size(), logger) : null;
- double maxodegree = 0;
+ DoubleMinMax minmax = new DoubleMinMax();
WritableDataStore<Double> knno_score = DataStoreUtil.makeStorage(relation.getDBIDs(), DataStoreFactory.HINT_STATIC, Double.class);
// compute distance to the k nearest neighbor.
for(DBID id : distanceQuery.getRelation().iterDBIDs()) {
@@ -124,7 +125,7 @@ public class KNNOutlier<O, D extends NumberDistance<D, ?>> extends AbstractDista double dkn = knns.get(last).getDistance().doubleValue();
knno_score.put(id, dkn);
- maxodegree = Math.max(maxodegree, dkn);
+ minmax.put(dkn);
if(progressKNNDistance != null) {
progressKNNDistance.incrementProcessed(logger);
@@ -134,7 +135,7 @@ public class KNNOutlier<O, D extends NumberDistance<D, ?>> extends AbstractDista progressKNNDistance.ensureCompleted(logger);
}
Relation<Double> scoreres = new MaterializedRelation<Double>("kNN Outlier Score", "knn-outlier", TypeUtil.DOUBLE, knno_score, relation.getDBIDs());
- OutlierScoreMeta meta = new BasicOutlierScoreMeta(Double.NaN, maxodegree, 0.0, Double.POSITIVE_INFINITY);
+ OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0.0);
return new OutlierResult(meta, scoreres);
}
diff --git a/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNWeightOutlier.java b/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNWeightOutlier.java index 17292a9f..02e0789b 100644 --- a/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNWeightOutlier.java +++ b/src/de/lmu/ifi/dbs/elki/algorithm/outlier/KNNWeightOutlier.java @@ -40,6 +40,7 @@ import de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction; import de.lmu.ifi.dbs.elki.distance.distancevalue.NumberDistance;
import de.lmu.ifi.dbs.elki.logging.Logging;
import de.lmu.ifi.dbs.elki.logging.progress.FiniteProgress;
+import de.lmu.ifi.dbs.elki.math.DoubleMinMax;
import de.lmu.ifi.dbs.elki.database.relation.MaterializedRelation;
import de.lmu.ifi.dbs.elki.result.outlier.BasicOutlierScoreMeta;
import de.lmu.ifi.dbs.elki.result.outlier.OutlierResult;
@@ -113,7 +114,7 @@ public class KNNWeightOutlier<O, D extends NumberDistance<D, ?>> extends Abstrac }
FiniteProgress progressKNNWeight = logger.isVerbose() ? new FiniteProgress("KNNWOD_KNNWEIGHT for objects", relation.size(), logger) : null;
- double maxweight = 0;
+ DoubleMinMax minmax = new DoubleMinMax();
// compute distance to the k nearest neighbor. n objects with the highest
// distance are flagged as outliers
@@ -130,7 +131,7 @@ public class KNNWeightOutlier<O, D extends NumberDistance<D, ?>> extends Abstrac double doubleSkn = skn.getValue().doubleValue();
knnw_score.put(id, doubleSkn);
- maxweight = Math.max(maxweight, doubleSkn);
+ minmax.put(doubleSkn);
if(progressKNNWeight != null) {
progressKNNWeight.incrementProcessed(logger);
@@ -141,7 +142,7 @@ public class KNNWeightOutlier<O, D extends NumberDistance<D, ?>> extends Abstrac }
Relation<Double> res = new MaterializedRelation<Double>("Weighted kNN Outlier Score", "knnw-outlier", TypeUtil.DOUBLE, knnw_score, relation.getDBIDs());
- OutlierScoreMeta meta = new BasicOutlierScoreMeta(Double.NaN, maxweight, 0.0, Double.POSITIVE_INFINITY);
+ OutlierScoreMeta meta = new BasicOutlierScoreMeta(minmax.getMin(), minmax.getMax(), 0.0, Double.POSITIVE_INFINITY, 0.0);
return new OutlierResult(meta, res);
}
diff --git a/src/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java b/src/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java index 4679cc52..9d96a55f 100644 --- a/src/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java +++ b/src/de/lmu/ifi/dbs/elki/database/StaticArrayDatabase.java @@ -143,6 +143,7 @@ public class StaticArrayDatabase extends AbstractDatabase implements Database, P // TODO: this is an ugly hack this.idrep = new DBIDView(this, this.ids); relations.add(this.idrep); + getHierarchy().add(this, idrep); // insert into db - note: DBIDs should have been prepared before this! Relation<?>[] targets = alignColumns(objpackages); diff --git a/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java b/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java index e0437869..6e90af51 100644 --- a/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java +++ b/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java @@ -79,7 +79,7 @@ public class RandomDoubleVectorDatabaseConnection extends AbstractDatabaseConnec @Override public MultipleObjectsBundle loadData() { - VectorFieldTypeInformation<DoubleVector> type = VectorFieldTypeInformation.get(DoubleVector.class, dim); + VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation(DoubleVector.class, dim, new DoubleVector(new double[dim])); List<DoubleVector> vectors = new ArrayList<DoubleVector>(size); // Setup random generator @@ -178,4 +178,4 @@ public class RandomDoubleVectorDatabaseConnection extends AbstractDatabaseConnec return new RandomDoubleVectorDatabaseConnection(dim, size, seed, filters); } } -}
\ No newline at end of file +} diff --git a/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java.rej b/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java.rej new file mode 100644 index 00000000..d339c8ee --- /dev/null +++ b/src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java.rej @@ -0,0 +1,14 @@ +--- src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java (Revision 8763) ++++ src/de/lmu/ifi/dbs/elki/datasource/RandomDoubleVectorDatabaseConnection.java (Revision 8764) +@@ -76,10 +76,9 @@ + + private static final Logging logger = Logging.getLogger(RandomDoubleVectorDatabaseConnection.class); + +- + @Override + public MultipleObjectsBundle loadData() { +- VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, DoubleVector.STATIC, dim); ++ VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, dim, DoubleVector.STATIC); + List<DoubleVector> vectors = new ArrayList<DoubleVector>(size); + + // Setup random generator diff --git a/src/de/lmu/ifi/dbs/elki/evaluation/roc/ROC.java b/src/de/lmu/ifi/dbs/elki/evaluation/roc/ROC.java index 9716a586..1b37bfff 100644 --- a/src/de/lmu/ifi/dbs/elki/evaluation/roc/ROC.java +++ b/src/de/lmu/ifi/dbs/elki/evaluation/roc/ROC.java @@ -81,8 +81,6 @@ public class ROC { * @return area under curve */ public static <C extends Comparable<? super C>, T> List<DoubleDoublePair> materializeROC(int size, Set<? super T> ids, Iterator<? extends PairInterface<C, T>> nei) { - final double DELTA = 0.01 / (size * size); - int postot = ids.size(); int negtot = size - postot; int poscnt = 0; @@ -116,18 +114,23 @@ public class ROC { if(res.size() >= 2) { DoubleDoublePair last1 = res.get(res.size() - 2); DoubleDoublePair last2 = res.get(res.size() - 1); + final double ldx = last2.first - last1.first; + final double cdx = curneg - last2.first; + final double ldy = last2.second - last1.second; + final double cdy = curpos - last2.second; // vertical simplification - if((last1.first == last2.first) && (last2.first == curneg)) { + if((ldx == 0) && (cdx == 0)) { res.remove(res.size() - 1); } // horizontal simplification - else if((last1.second == last2.second) && (last2.second == curpos)) { + else if((ldy == 0) && (cdy == 0)) { res.remove(res.size() - 1); } // diagonal simplification - // TODO: Make a test. - else if(Math.abs((last2.first - last1.first) - (curneg - last2.first)) < DELTA && Math.abs((last2.second - last1.second) - (curpos - last2.second)) < DELTA) { - res.remove(res.size() - 1); + else if(ldy > 0 && cdy > 0) { + if(Math.abs((ldx / ldy) - (cdx / cdy)) < 1E-10) { + res.remove(res.size() - 1); + } } } // Add a new point (for the previous entry!) @@ -135,7 +138,8 @@ public class ROC { prev = cur; } // ensure we end up in the top right corner. - // Since we didn't add a point for the last entry yet, this likely is needed. + // Since we didn't add a point for the last entry yet, this likely is + // needed. { DoubleDoublePair last = res.get(res.size() - 1); if(last.first < 1.0 || last.second < 1.0) { diff --git a/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java b/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java index 9e76b474..4fafe1bb 100644 --- a/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java +++ b/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/AbstractRStarTree.java @@ -156,7 +156,7 @@ public abstract class AbstractRStarTree<N extends AbstractRStarTreeNode<N, E>, E N node = getNode(subtree.getLastPathComponent().getEntry()); if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { - if(((LeafEntry) node.getEntry(i)).getDBID() == id) { + if(((LeafEntry) node.getEntry(i)).getDBID().equals(id)) { return subtree.pathByAddingChild(new TreeIndexPathComponent<E>(node.getEntry(i), i)); } } diff --git a/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java b/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java index 9bf6be8f..062ddfb2 100644 --- a/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java +++ b/src/de/lmu/ifi/dbs/elki/index/tree/spatial/rstarvariants/deliclu/DeLiCluTreeIndex.java @@ -44,6 +44,7 @@ import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.query.RStarTreeUtil; import de.lmu.ifi.dbs.elki.index.tree.spatial.rstarvariants.util.InsertionStrategy; import de.lmu.ifi.dbs.elki.logging.Logging; import de.lmu.ifi.dbs.elki.persistent.PageFile; +import de.lmu.ifi.dbs.elki.utilities.exceptions.AbortException; /** * The common use of the DeLiClu tree: indexing number vectors. @@ -103,7 +104,7 @@ public class DeLiCluTreeIndex<O extends NumberVector<?, ?>> extends DeLiCluTree IndexTreePath<DeLiCluEntry> pathToObject = findPathToObject(getRootPath(), obj, id); if(pathToObject == null) { - return null; + throw new AbortException("Object not found in setHandled."); } // set o handled diff --git a/src/de/lmu/ifi/dbs/elki/math/ConvexHull2D.java b/src/de/lmu/ifi/dbs/elki/math/ConvexHull2D.java index 3317e500..10a27f38 100644 --- a/src/de/lmu/ifi/dbs/elki/math/ConvexHull2D.java +++ b/src/de/lmu/ifi/dbs/elki/math/ConvexHull2D.java @@ -83,6 +83,7 @@ public class ConvexHull2D { public void add(Vector point) {
if (this.ok) {
this.points = new LinkedList<Vector>(this.points);
+ this.ok = false;
}
this.points.add(point);
// Update data set extends
@@ -115,7 +116,7 @@ public class ConvexHull2D { Collections.sort(this.points, new Comparator<Vector>() {
@Override
public int compare(Vector o1, Vector o2) {
- return isLeft(o1, o2, origin) ? +1 : 0;
+ return isLeft(o1, o2, origin) ? +1 : -1;
}
});
@@ -125,7 +126,7 @@ public class ConvexHull2D { /**
* Find the starting point, and sort it to the beginning of the list. The
- * starting point must be on the outer hull. Any "skyline" point will do, e.g.
+ * starting point must be on the outer hull. Any "most extreme" point will do, e.g.
* the one with the lowest Y coordinate and for ties with the lowest X.
*/
private void findStartingPoint() {
diff --git a/src/de/lmu/ifi/dbs/elki/math/MathUtil.java b/src/de/lmu/ifi/dbs/elki/math/MathUtil.java index 6856a44b..83fbca92 100644 --- a/src/de/lmu/ifi/dbs/elki/math/MathUtil.java +++ b/src/de/lmu/ifi/dbs/elki/math/MathUtil.java @@ -244,12 +244,13 @@ public final class MathUtil { double meanX = x[0]; double meanY = y[0]; for(int i = 1; i < xdim; i++) { + int sumWe = i + 1; // Delta to previous mean final double deltaX = x[i] - meanX; final double deltaY = y[i] - meanY; // Update means - meanX += deltaX / i; - meanY += deltaY / i; + meanX += deltaX / sumWe; + meanY += deltaY / sumWe; // Delta to new mean final double neltaX = x[i] - meanX; final double neltaY = y[i] - meanY; diff --git a/src/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/StandardDeviationScaling.java b/src/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/StandardDeviationScaling.java index 62223730..10db8e56 100644 --- a/src/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/StandardDeviationScaling.java +++ b/src/de/lmu/ifi/dbs/elki/utilities/scaling/outlier/StandardDeviationScaling.java @@ -122,6 +122,9 @@ public class StandardDeviationScaling implements OutlierScalingFunction { } mean = mv.getMean(); factor = lambda * mv.getSampleStddev() * MathUtil.SQRT2; + if (factor == 0.0) { + factor = Double.MIN_NORMAL; + } } else { mean = fixedmean; @@ -135,6 +138,9 @@ public class StandardDeviationScaling implements OutlierScalingFunction { } } factor = lambda * Math.sqrt(sqsum / cnt) * MathUtil.SQRT2; + if (factor == 0.0) { + factor = Double.MIN_NORMAL; + } } } diff --git a/src/de/lmu/ifi/dbs/elki/visualization/VisualizationTask.java b/src/de/lmu/ifi/dbs/elki/visualization/VisualizationTask.java index 04d2c5eb..3cf05e37 100644 --- a/src/de/lmu/ifi/dbs/elki/visualization/VisualizationTask.java +++ b/src/de/lmu/ifi/dbs/elki/visualization/VisualizationTask.java @@ -324,7 +324,7 @@ public class VisualizationTask extends AnyMap<String> implements Cloneable, Resu Integer level1 = this.get(VisualizationTask.META_LEVEL, Integer.class); Integer level2 = other.get(VisualizationTask.META_LEVEL, Integer.class); if(level1 != null && level2 != null && level1 != level2) { - return level1 - level2; + return level2 - level1; } // sort by name otherwise. String name1 = this.getShortName(); diff --git a/src/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java b/src/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java index ad87c3fc..505e61d8 100644 --- a/src/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java +++ b/src/de/lmu/ifi/dbs/elki/visualization/gui/overview/RectangleArranger.java @@ -252,18 +252,6 @@ public class RectangleArranger<T> { assert assertConsistent(); } logger.debugFinest("Best: " + bestsx + "," + bestsy + " - " + bestex + "," + bestey + " inc: " + bestwi + "x" + besthi + " " + bestinc); - // Need to split a column. - // TODO: find best column to split. Currently: last - if(bestwi < 0) { - splitCol(bestex, -bestwi); - bestwi = 0.0; - } - // Need to split a row. - // TODO: find best row to split. Currently: last - if(besthi < 0) { - splitRow(bestey, -besthi); - besthi = 0.0; - } // Need to increase the total area if(bestinc > 0) { assert (bestex == cols - 1 || bestey == rows - 1); @@ -274,6 +262,18 @@ public class RectangleArranger<T> { put(w, h, data); return; } + // Need to split a column. + // TODO: find best column to split. Currently: last + if(bestwi < 0.0) { + splitCol(bestex, -bestwi); + bestwi = 0.0; + } + // Need to split a row. + // TODO: find best row to split. Currently: last + if(besthi < 0.0) { + splitRow(bestey, -besthi); + besthi = 0.0; + } for(int x = bestsx; x <= bestex; x++) { for(int y = bestsy; y <= bestey; y++) { usage.get(y).set(x, data); @@ -371,7 +371,7 @@ public class RectangleArranger<T> { { double wsum = 0.0; for(int x = 0; x < cols; x++) { - assert (widths.get(x) > 0); + assert (widths.get(x) > 0) : "Negative width: "+widths.get(x); wsum += widths.get(x); } assert (Math.abs(wsum - twidth) < 1E-10); @@ -379,7 +379,7 @@ public class RectangleArranger<T> { { double hsum = 0.0; for(int y = 0; y < rows; y++) { - assert (heights.get(y) > 0); + assert (heights.get(y) > 0) : "Negative height: "+heights.get(y); hsum += heights.get(y); } assert (Math.abs(hsum - theight) < 1E-10); diff --git a/test/de/lmu/ifi/dbs/elki/math/TestMathUtil.java b/test/de/lmu/ifi/dbs/elki/math/TestMathUtil.java new file mode 100644 index 00000000..16dfe77c --- /dev/null +++ b/test/de/lmu/ifi/dbs/elki/math/TestMathUtil.java @@ -0,0 +1,58 @@ +package de.lmu.ifi.dbs.elki.math; + +import static org.junit.Assert.*; + +import java.util.Random; + +import org.junit.Test; + +import de.lmu.ifi.dbs.elki.JUnit4Test; +/* + This file is part of ELKI: + Environment for Developing KDD-Applications Supported by Index-Structures + + Copyright (C) 2011 + Ludwig-Maximilians-Universität München + Lehr- und Forschungseinheit für Datenbanksysteme + ELKI Development Team + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +public class TestMathUtil implements JUnit4Test { + + @Test + public void testPearsonCorrelation() { + final int size = 1000; + final long seed = 1; + double[] data1 = new double[size]; + double[] data2 = new double[size]; + double[] weight1 = new double[size]; + double[] weight2 = new double[size]; + + Random r = new Random(seed); + for (int i = 0; i < size; i++) { + data1[i] = r.nextDouble(); + data2[i] = r.nextDouble(); + weight1[i] = 1.0; + weight2[i] = 0.1; + } + + double pear = MathUtil.pearsonCorrelationCoefficient(data1, data2); + double wpear1 = MathUtil.weightedPearsonCorrelationCoefficient(data1, data2, weight1); + double wpear2 = MathUtil.weightedPearsonCorrelationCoefficient(data1, data2, weight2); + assertEquals("Pearson and weighted pearson should be the same with constant weights.", pear, wpear1, 1E-10); + assertEquals("Weighted pearsons should be the same with constant weights.", wpear1, wpear2, 1E-10); + } +} |