Examples of MeanCalculator


Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

    final double[] rho = new AutocorrelationFunctionCalculator().evaluate(MA);
    final double rho1 = PHI[1] / (1 - PHI[2]);
    assertEquals(rho[0], 1, 1e-16);
    assertEquals(rho[1], rho1, eps);
    assertEquals(rho[2], rho1 * PHI[1] + PHI[2], eps);
    final Double mean = new DoubleTimeSeriesStatisticsCalculator(new MeanCalculator()).evaluate(MA);
    assertEquals(mean, PHI[0] / (1 - PHI[1] - PHI[2]), eps);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

        assertTrue(rho[i] > LIMIT);
      } else {
        assertTrue(rho[i] < LIMIT);
      }
    }
    final Double mean = new DoubleTimeSeriesStatisticsCalculator(new MeanCalculator()).evaluate(MA);
    assertEquals(mean, THETA[0], eps);
    final Double variance = new DoubleTimeSeriesStatisticsCalculator(new SampleVarianceCalculator()).evaluate(MA);
    double sum = 1;
    for (int i = 1; i <= ORDER; i++) {
      sum += THETA[i] * THETA[i];
 
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

   * @param nSteps Number of steps
   * @param nu Computed by getShiftedDrift method
   * @return space step
   */
  public double getSpaceStep(final double timeToExpiry, final double[] volatility, final int nSteps, final double[] nu) {
    final Function1D<double[], Double> calculator = new MeanCalculator();
    final double meanNu = calculator.evaluate(nu);
    final double meanVol = calculator.evaluate(volatility);
    final double dt = timeToExpiry / nSteps;

    return Math.sqrt(meanVol * meanVol * dt + meanNu * meanNu * dt * dt);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

   * @param nu Computed by getShiftedDrift method
   * @param dt time step
   * @return space step
   */
  public double getSpaceStepTrinomial(final double[] volatility, final double[] nu, final double dt) {
    final Function1D<double[], Double> calculator = new MeanCalculator();
    final double meanNu = calculator.evaluate(nu);
    final double meanVol = calculator.evaluate(volatility);

    return Math.sqrt(3. * meanVol * meanVol * dt + meanNu * meanNu * dt * dt);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

  private double[] normaliseData(final double[] xData) {

    final int nData = xData.length;
    final double[] res = new double[nData];

    Function1D<double[], Double> calculator = new MeanCalculator();
    _renorm[0] = calculator.evaluate(xData);
    calculator = new SampleStandardDeviationCalculator();
    _renorm[1] = calculator.evaluate(xData);

    final double tmp = _renorm[0] / _renorm[1];
    for (int i = 0; i < nData; ++i) {
      res[i] = xData[i] / _renorm[1] - tmp;
    }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

  @Test
  public void test() {
    assertCDFWithNull(LAPLACE);
    assertPDFWithNull(LAPLACE);
    assertInverseCDFWithNull(LAPLACE);
    final double mean = new MeanCalculator().evaluate(DATA);
    final double median = new MedianCalculator().evaluate(DATA);
    final double variance = new SampleVarianceCalculator().evaluate(DATA);
    final double skew = new SampleSkewnessCalculator().evaluate(DATA);
    final double kurtosis = new SampleFisherKurtosisCalculator().evaluate(DATA);
    assertEquals(mean, MU, EPS1);
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

    assertEquals(dist.getCDF(limit - 1e-15), 1, EPS);
  }

  @Test
  public void testDistribution() {
    final Function1D<double[], Double> meanCalculator = new MeanCalculator();
    final Function1D<double[], Double> medianCalculator = new MedianCalculator();
    final Function1D<double[], Double> varianceCalculator = new PopulationVarianceCalculator();
    final int n = 1000000;
    final double eps = 0.1;
    final double[] data = new double[n];
    for (int i = 0; i < n; i++) {
      data[i] = DIST.nextRandom();
    }
    final double mean = MU + SIGMA / (1 - KSI);
    final double median = MU + SIGMA * (Math.pow(2, KSI) - 1) / KSI;
    final double variance = SIGMA * SIGMA / ((1 - KSI) * (1 - KSI) * (1 - 2 * KSI));
    assertEquals(meanCalculator.evaluate(data), mean, eps);
    assertEquals(medianCalculator.evaluate(data), median, eps);
    assertEquals(varianceCalculator.evaluate(data), variance, eps);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

  // Calculate the average notional of the obligors in the underlying pool
  public double getUnderlyingPoolNotionalMean(final UnderlyingPool underlyingPool) {

    ArgumentChecker.notNull(underlyingPool, "Underlying pool");

    MeanCalculator mean = new MeanCalculator();

    return mean.evaluate(underlyingPool.getObligorNotionals());
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

  // Calculate the average recovery rate of the obligors in the underlying pool
  public double getUnderlyingPoolRecoveryRateMean(final UnderlyingPool underlyingPool) {

    ArgumentChecker.notNull(underlyingPool, "Underlying pool");

    MeanCalculator mean = new MeanCalculator();

    double[] recoveryRates = underlyingPool.getRecoveryRates();

    return mean.evaluate(recoveryRates);
  }
View Full Code Here

Examples of com.opengamma.analytics.math.statistics.descriptive.MeanCalculator

    ArgumentChecker.notNull(underlyingPool, "Underlying pool");
    ArgumentChecker.notNull(creditSpreadTenors, "Credit spread tenors");
    ArgumentChecker.notNull(creditSpreadTermStructures, "Credit spread term structures");
    ArgumentChecker.notNull(creditSpreadTenor, "Credit spread tenor");

    MeanCalculator mean = new MeanCalculator();

    double[] spreads = getSpreads(underlyingPool, creditSpreadTenors, creditSpreadTermStructures, creditSpreadTenor);

    return mean.evaluate(spreads);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.