Пример #1
0
  public double[][] getXYMinMax() {

    int[] indicesX = new int[x.length];
    int[] indicesY = new int[y.length];
    HeapSort.sort(x, indicesX);
    HeapSort.sort(y, indicesY);

    double[][] returnArray = new double[2][2];
    returnArray[0][0] = x[indicesX[0]];
    returnArray[0][1] = x[indicesX[indicesX.length - 1]];
    returnArray[1][0] = y[indicesY[0]];
    returnArray[1][1] = y[indicesY[indicesY.length - 1]];

    return returnArray;
  }
Пример #2
0
  /**
   * compute median
   *
   * @param x list of numbers
   * @return median
   */
  public static double median(double[] x) {

    if (x == null || x.length == 0) {
      throw new IllegalArgumentException();
    }

    int[] indices = new int[x.length];
    HeapSort.sort(x, indices);

    return median(x, indices);
  }
Пример #3
0
  /**
   * compute the cumulative probability Pr(x <= z) for a given z and a distribution of x
   *
   * @param z threshold value
   * @param x discrete distribution (an unordered list of numbers)
   * @return cumulative probability
   */
  public static double cdf(double z, double[] x) {
    int[] indices = new int[x.length];
    HeapSort.sort(x, indices);

    return cdf(z, x, indices);
  }
Пример #4
0
  /**
   * compute the q-th quantile for a distribution of x (= inverse cdf)
   *
   * @param q quantile (0 <= q <= 1)
   * @param x discrete distribution (an unordered list of numbers)
   * @param count use only first count entries in x
   * @return q-th quantile
   */
  public static double quantile(double q, double[] x, int count) {
    int[] indices = new int[count];
    HeapSort.sort(x, indices);

    return quantile(q, x, indices);
  }
Пример #5
0
  /**
   * compute the q-th quantile for a distribution of x (= inverse cdf)
   *
   * @param q quantile (0 <= q <= 1)
   * @param x discrete distribution (an unordered list of numbers)
   * @return q-th quantile
   */
  public static double quantile(double q, double[] x) {
    int[] indices = new int[x.length];
    HeapSort.sort(x, indices);

    return quantile(q, x, indices);
  }