Codota Logo
Distance
Code IndexAdd Codota to your IDE (free)

How to use
Distance
in
smile.math.distance

Best Java code snippets using smile.math.distance.Distance (Showing top 7 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
SimpleDateFormat s =
  • Codota IconString pattern;new SimpleDateFormat(pattern)
  • Codota IconString template;Locale locale;new SimpleDateFormat(template, locale)
  • Codota Iconnew SimpleDateFormat()
  • Smart code suggestions by Codota
}
origin: com.github.haifengl/smile-core

/**
 * Cluster a new instance.
 * @param x a new instance.
 * @return the cluster label, which is the index of nearest medoid.
 */
@Override
public int predict(T x) {
  double minDist = Double.MAX_VALUE;
  int bestCluster = 0;
  for (int i = 0; i < k; i++) {
    double dist = distance.d(x, medoids[i]);
    if (dist < minDist) {
      minDist = dist;
      bestCluster = i;
    }
  }
  return bestCluster;
}
origin: com.github.haifengl/smile-core

  @Override
  public void range(T q, double radius, List<Neighbor<T,T>> neighbors) {
    if (radius <= 0.0) {
      throw new IllegalArgumentException("Invalid radius: " + radius);
    }

    for (int i = 0; i < data.length; i++) {
      if (q == data[i] && identicalExcluded) {
        continue;
      }

      double d = distance.d(q, data[i]);

      if (d <= radius) {
        neighbors.add(new SimpleNeighbor<>(data[i], i, d));
      }
    }
  }
}
origin: com.github.haifengl/smile-core

@Override
public Neighbor<T,T> nearest(T q) {
  T neighbor = null;
  int index = -1;
  double dist = Double.MAX_VALUE;
  for (int i = 0; i < data.length; i++) {
    if (q == data[i] && identicalExcluded) {
      continue;
    }
    double d = distance.d(q, data[i]);
    if (d < dist) {
      neighbor = data[i];
      index = i;
      dist = d;
    }
  }
  return new SimpleNeighbor<>(neighbor, index, dist);
}
origin: com.github.haifengl/smile-math

double cost = distance.d(x1[i-1], x2[j-1]);
origin: com.github.haifengl/smile-core

double dist = distance.d(data[i], medoid);
if (d[i] > dist) {
  y[i] = index;
  for (int j = 0; j < k; j++) {
    if (j != index) {
      dist = distance.d(data[i], medoids[j]);
      if (d[i] > dist) {
        y[i] = j;
origin: com.github.haifengl/smile-core

  double dist = distance.d(data[i], medoid);
  if (dist < d[i]) {
    d[i] = dist;
double dist = distance.d(data[i], medoid);
if (dist < d[i]) {
  d[i] = dist;
origin: com.github.haifengl/smile-core

double dist = distance.d(q, data[i]);
Neighbor<T,T> datum = heap.peek();
if (dist < datum.distance) {
smile.math.distanceDistance

Javadoc

An interface to calculate a distance measure between two objects. A distance function maps pairs of points into the nonnegative reals and has to satisfy
  • non-negativity: d(x, y) ≥ 0
  • isolation: d(x, y) = 0 if and only if x = y
  • symmetry: d(x, y) = d(x, y)
. Note that a distance function is not required to satisfy triangular inequality |x - y| + |y - z| ≥ |x - z|, which is necessary for a metric.

Most used methods

  • d
    Returns the distance measure between two objects.

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • onCreateOptionsMenu (Activity)
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now