congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
QuickSelect.select
Code IndexAdd Tabnine to your IDE (free)

How to use
select
method
in
smile.sort.QuickSelect

Best Java code snippets using smile.sort.QuickSelect.select (Showing top 14 results out of 315)

origin: com.github.haifengl/smile-math

/**
 * Find the median of an array of type integer.
 */
public static int median(int[] a) {
  int k = a.length / 2;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the third quantile (p = 3/4) of an array of type float.
 */
public static float q3(float[] a) {
  int k = 3 * a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the first quantile (p = 1/4) of an array of type double.
 */
public static double q1(double[] a) {
  int k = a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the first quantile (p = 1/4) of an array of type double.
 */
public static <T extends Comparable<? super T>> T q1(T[] a) {
  int k = a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the median of an array of type double.
 */
public static double median(double[] a) {
  int k = a.length / 2;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the third quantile (p = 3/4) of an array of type integer.
 */
public static int q3(int[] a) {
  int k = 3 * a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

  /**
   * Find the third quantile (p = 3/4) of an array of type double.
   */
  public static <T extends Comparable<? super T>> T q3(T[] a) {
    int k = 3 * a.length / 4;
    return select(a, k);
  }
}
origin: com.github.haifengl/smile-math

/**
 * Find the median of an array of type float.
 */
public static float median(float[] a) {
  int k = a.length / 2;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the first quantile (p = 1/4) of an array of type integer.
 */
public static int q1(int[] a) {
  int k = a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the third quantile (p = 3/4) of an array of type double.
 */
public static double q3(double[] a) {
  int k = 3 * a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the median of an array of type double.
 */
public static <T extends Comparable<? super T>> T median(T[] a) {
  int k = a.length / 2;
  return select(a, k);
}
origin: com.github.haifengl/smile-math

/**
 * Find the first quantile (p = 1/4) of an array of type float.
 */
public static float q1(float[] a) {
  int k = a.length / 4;
  return select(a, k);
}
origin: com.github.haifengl/smile-core

@Override
public void learn(Attribute[] attributes, double[][] data) {
  int n = data.length;
  int p = data[0].length;
  int i1 = (int) Math.round(lower * n);
  int i2 = (int) Math.round(upper * n);
  if (i2 == n) {
    i2 = n - 1;
  }
  lo = new double[p];
  hi = new double[p];
  double[] x = new double[n];
  for (int j = 0; j < p; j++) {
    if (attributes[j].getType() != Attribute.Type.NUMERIC) {
      lo[j] = Double.NaN;
    } else {
      for (int i = 0; i < n; i++) {
        x[i] = data[i][j];
      }
      lo[j] = QuickSelect.select(x, i1);
      hi[j] = QuickSelect.select(x, i2) - lo[j];
      if (Math.isZero(hi[j])) {
        throw new IllegalArgumentException("Attribute " + j + " has constant values in the given range.");
      }
    }
  }
}
origin: com.github.haifengl/smile-core

/**
 * Constructor.
 */
public HuberNodeOutput(double[] residual, double[] response, double alpha) {
  this.residual = residual;
  this.response = response;
  this.alpha = alpha;
  
  int n = residual.length;
  for (int i = 0; i < n; i++) {
    response[i] = Math.abs(residual[i]);
  }
  
  delta = QuickSelect.select(response, (int) (n * alpha));
  
  for (int i = 0; i < n; i++) {
    if (Math.abs(residual[i]) <= delta) {
      response[i] = residual[i];
    } else {
      response[i] = delta * Math.signum(residual[i]);
    }
  }
}

smile.sortQuickSelectselect

Javadoc

Given k in [0, n-1], returns an array value from arr such that k array values are less than or equal to the one returned. The input array will be rearranged to have this value in location arr[k], with all smaller elements moved to arr[0, k-1] (in arbitrary order) and all larger elements in arr[k+1, n-1] (also in arbitrary order).

Popular methods of QuickSelect

  • median
    Find the median of an array of type double.
  • q1
    Find the first quantile (p = 1/4) of an array of type double.
  • q3
    Find the third quantile (p = 3/4) of an array of type double.

Popular in Java

  • Running tasks concurrently on multiple threads
  • getContentResolver (Context)
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • JFileChooser (javax.swing)
  • Join (org.hibernate.mapping)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now