예제 #1
0
  /**
   * Computes the value of h(x) given the mixture.
   *
   * @param AHat the value
   * @return the value of h(x)
   */
  public double h(double AHat) {

    if (AHat == 0.0) return 0.0;
    DoubleVector points = mixingDistribution.getPointValues();
    DoubleVector values = mixingDistribution.getFunctionValues();

    double aHat = Math.sqrt(AHat);
    DoubleVector aStar = points.sqrt();
    DoubleVector d1 = Maths.dnorm(aHat, aStar, 1).timesEquals(values);
    DoubleVector d2 = Maths.dnorm(-aHat, aStar, 1).timesEquals(values);

    return points.minus(aHat / 2).innerProduct(d1) - points.plus(aHat / 2).innerProduct(d2);
  }
 /**
  * Computes the value of h(x) given the mixture.
  *
  * @param x the value
  * @return the value of h(x)
  */
 public double h(double x) {
   DoubleVector points = mixingDistribution.getPointValues();
   DoubleVector values = mixingDistribution.getFunctionValues();
   DoubleVector d = (DoubleVector) Maths.dnorm(x, points, 1).timesEquals(values);
   return ((DoubleVector) points.times(2 * x).minusEquals(x * x)).innerProduct(d);
 }