Examples of distance()


Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D.distance()

                    // Jacobian of the radius residuals.
                    double[][] jacobian = new double[n][2];
                    for (int i = 0; i < n; i++) {
                        final Vector2D pi = points.get(i);
                        final double di = pi.distance(center);
                        jacobian[i][0] = (center.getX() - pi.getX()) / di - dRdX;
                        jacobian[i][1] = (center.getY() - pi.getY()) / di - dRdY;
                    }

                    return jacobian;
View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D.distance()

        final double tolerance = getTolerance();

        if (hull.size() == 1) {
            // ensure that we do not add an identical point
            final Vector2D p1 = hull.get(0);
            if (p1.distance(point) < tolerance) {
                return;
            }
        }

        while (hull.size() >= 2) {
View Full Code Here

Examples of org.apache.commons.math3.geometry.euclidean.twod.Vector2D.distance()

            final double offset = new Line(p1, p2, tolerance).getOffset(point);
            if (FastMath.abs(offset) < tolerance) {
                // the point is collinear to the line (p1, p2)

                final double distanceToCurrent = p1.distance(point);
                if (distanceToCurrent < tolerance || p2.distance(point) < tolerance) {
                    // the point is assumed to be identical to either p1 or p2
                    return;
                }

                final double distanceToLast = p1.distance(p2);
View Full Code Here

Examples of org.apache.mahout.common.distance.CosineDistanceMeasure.distance()

    double min = Double.MAX_VALUE;
    double sum = 0;
    int count = 0;
    for (int i = 0; i < clusters.size(); i++) {
      for (int j = i + 1; j < clusters.size(); j++) {
        double d = measure.distance(clusters.get(i)
            .getCenter(), clusters.get(j).getCenter());
        min = Math.min(d, min);
        max = Math.max(d, max);
        sum += d;
        count++;
View Full Code Here

Examples of org.apache.mahout.common.distance.DistanceMeasure.distance()

    double min = Double.MAX_VALUE;
    double sum = 0;
    int count = 0;
    for (int i = 0; i < clusters.size(); i++) {
      for (int j = i + 1; j < clusters.size(); j++) {
        double d = measure.distance(clusters.get(i)
            .getCenter(), clusters.get(j).getCenter());
        min = Math.min(d, min);
        max = Math.max(d, max);
        sum += d;
        count++;
View Full Code Here

Examples of org.apache.mahout.common.distance.EuclideanDistanceMeasure.distance()

      Map<String,Cluster> clusterMap = loadClusterMap(clusters);
      for (String key : collector.getKeys()) {
        Cluster cluster = clusterMap.get(key);
        List<KMeansInfo> values = collector.getValue(key);
        for (KMeansInfo value : values) {
          double distance = euclideanDistanceMeasure.distance(cluster.getCenter(), value.getPointTotal());
          for (Cluster c : clusters) {
            assertTrue("distance error", distance <= euclideanDistanceMeasure.distance(value.getPointTotal(),
              c.getCenter()));
          }
        }
View Full Code Here

Examples of org.apache.mahout.common.distance.EuclideanDistanceMeasure.distance()

        Cluster cluster = clusterMap.get(key);
        List<KMeansInfo> values = collector.getValue(key);
        for (KMeansInfo value : values) {
          double distance = euclideanDistanceMeasure.distance(cluster.getCenter(), value.getPointTotal());
          for (Cluster c : clusters) {
            assertTrue("distance error", distance <= euclideanDistanceMeasure.distance(value.getPointTotal(),
              c.getCenter()));
          }
        }
      }
    }
View Full Code Here

Examples of org.apache.mahout.common.distance.ManhattanDistanceMeasure.distance()

    FileWriter writer = new FileWriter(affinities.toString());
    PrintWriter out = new PrintWriter(writer);
    try {
      for (int i = 0; i < SAMPLE_DATA.size(); i++) {
        for (int j = 0; j < SAMPLE_DATA.size(); j++) {
          out.println(i + "," + j + "," + measure.distance(SAMPLE_DATA.get(i).get(), SAMPLE_DATA.get(j).get()));
        }
      }
    } finally {
      out.close();
    }
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure.distance()

    // Given the centroid, we can compute \Delta_1^2(X), the total squared distance for the datapoints
    // this accelerates seed selection.
    double radius = 0;
    DistanceMeasure l2 = new SquaredEuclideanDistanceMeasure();
    for (WeightedVector row : datapoints) {
      radius += l2.distance(row, center);
    }

    // Find the first seed c_1 (and conceptually the second, c_2) as might be done in the 2-means clustering so that
    // the probability of selecting c_1 and c_2 is proportional to || c_1 - c_2 ||^2.  This is done
    // by first selecting c_1 with probability:
View Full Code Here

Examples of org.apache.mahout.utils.EuclideanDistanceMeasure.distance()

        List<Text> values = collector.getValue(key);
        for (Writable value : values) {
          String[] pointInfo = value.toString().split("\t");

          Vector point = AbstractVector.decodeVector(pointInfo[1]);
          double distance = euclideanDistanceMeasure.distance(cluster
              .getCenter(), point);
          for (Cluster c : clusters)
            assertTrue("distance error", distance <= euclideanDistanceMeasure
                .distance(point, c.getCenter()));
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.