Beispiel #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;
  }
  /**
   * 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);
  }
  /**
   * 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);
  }
  /**
   * 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);
  }
  /**
   * 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);
  }