Example usage for org.apache.commons.math.stat.descriptive.rank Min Min

List of usage examples for org.apache.commons.math.stat.descriptive.rank Min Min

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.descriptive.rank Min Min.

Prototype

public Min() 

Source Link

Document

Create a Min instance

Usage

From source file:com.discursive.jccook.math.StatExample.java

public static void main(String[] args) {
    double[] values = new double[] { 2.3, 5.4, 6.2, 7.3, 23.3 };

    System.out.println("min: " + StatUtils.min(values));
    System.out.println("max: " + StatUtils.max(values));
    System.out.println("mean: " + StatUtils.mean(values));
    System.out.println("product: " + StatUtils.product(values));
    System.out.println("sum: " + StatUtils.sum(values));
    System.out.println("variance: " + StatUtils.variance(values));

    // Measures from previous example
    Min min = new Min();
    System.out.println("min: " + min.evaluate(values));
    Max max = new Max();
    System.out.println("max: " + max.evaluate(values));
    Mean mean = new Mean();
    System.out.println("mean: " + mean.evaluate(values));
    Product product = new Product();
    System.out.println("product: " + product.evaluate(values));
    Sum sum = new Sum();
    System.out.println("sum: " + sum.evaluate(values));
    Variance variance = new Variance();
    System.out.println("variance: " + variance.evaluate(values));

    // New measures
    Percentile percentile = new Percentile();
    System.out.println("80 percentile value: " + percentile.evaluate(values, 80.0));
    GeometricMean geoMean = new GeometricMean();
    System.out.println("geometric mean: " + geoMean.evaluate(values));
    StandardDeviation stdDev = new StandardDeviation();
    System.out.println("standard dev: " + stdDev.evaluate(values));
    Skewness skewness = new Skewness();
    System.out.println("skewness: " + skewness.evaluate(values));
    Kurtosis kurtosis = new Kurtosis();
    System.out.println("kurtosis: " + kurtosis.evaluate(values));

}

From source file:fr.ens.transcriptome.corsen.util.StatTest.java

public void testMin() {

    Min min = new Min();

    for (int i = 0; i < 10000; i++) {

        List<DataDouble> list = generate();
        assertEquals(min.evaluate(Stats.toDouble(list)), Stats.min(list));
    }/*  w  ww . j a  v  a2 s.c  o m*/
}

From source file:com.opengamma.analytics.financial.interestrate.future.provider.BondFuturesSecurityDiscountingMethodTest.java

@Test
/**//from w w w .j  av a  2s. c  om
 * Tests the net basis of all bonds computed from the curves.
 */
public void netBasisAllBonds() {
    //final double priceFuture = 1.0320;
    final double priceFuture = METHOD_FUT_SEC_DSC.price(BOND_FUTURE, ISSUER_MULTICURVES);
    final double[] netBasisComputed = METHOD_FUT_SEC_DSC.netBasisAllBonds(BOND_FUTURE, ISSUER_MULTICURVES,
            priceFuture);
    final double[] netBasisExpected = new double[NB_BOND];
    for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) {
        final double bondPriceForward = METHOD_BOND_SEC
                .dirtyPriceFromCurves(BOND_FUTURE.getDeliveryBasket()[loopbasket], ISSUER_MULTICURVES);
        netBasisExpected[loopbasket] = bondPriceForward - (priceFuture * CONVERSION_FACTOR[loopbasket]
                + BOND_FUTURE.getDeliveryBasket()[loopbasket].getAccruedInterest());
        assertEquals("Bond future security Discounting Method: netBasis", netBasisExpected[loopbasket],
                netBasisComputed[loopbasket], 1.0E-10);
    }
    final Min minFunction = new Min();
    final double netBasisMin = minFunction.evaluate(netBasisComputed);
    final double priceFutureFromNetBasis = METHOD_FUT_SEC_DSC.priceFromNetBasis(BOND_FUTURE, ISSUER_MULTICURVES,
            netBasisMin);
    assertEquals("Bond future security Discounting Method: netBasis", priceFuture, priceFutureFromNetBasis,
            1.0E-10);
}

From source file:com.opengamma.analytics.financial.interestrate.future.provider.BondFutureDiscountingMethodTest.java

@Test
/**/*from   w  w  w  .  j  a  va  2s  . c  o  m*/
 * Tests the net basis of all bonds computed from the curves.
 */
public void netBasisAllBonds() {
    //final double priceFuture = 1.0320;
    final double priceFuture = METHOD_FUT_DSC.price(BOND_FUTURE, ISSUER_MULTICURVES);
    final double[] netBasisComputed = METHOD_FUT_DSC.netBasisAllBonds(BOND_FUTURE, ISSUER_MULTICURVES,
            priceFuture);
    final double[] netBasisExpected = new double[NB_BOND];
    for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) {
        final double bondPriceForward = METHOD_BOND
                .dirtyPriceFromCurves(BOND_FUTURE.getDeliveryBasket()[loopbasket], ISSUER_MULTICURVES);
        netBasisExpected[loopbasket] = bondPriceForward - (priceFuture * CONVERSION_FACTOR[loopbasket]
                + BOND_FUTURE.getDeliveryBasket()[loopbasket].getAccruedInterest());
        assertEquals("Bond future security Discounting Method: netBasis", netBasisExpected[loopbasket],
                netBasisComputed[loopbasket], 1.0E-10);
    }
    final Min minFunction = new Min();
    final double netBasisMin = minFunction.evaluate(netBasisComputed);
    final double priceFutureFromNetBasis = METHOD_FUT_DSC.priceFromNetBasis(BOND_FUTURE, ISSUER_MULTICURVES,
            netBasisMin);
    assertEquals("Bond future security Discounting Method: netBasis", priceFuture, priceFutureFromNetBasis,
            1.0E-10);
}

From source file:com.opengamma.analytics.financial.interestrate.future.method.BondFutureSecurityDiscountingMethodTest.java

@Test
/**//w  ww  . ja  v  a  2s. c  om
 * Tests the net basis computed from the curves.
 */
public void netBasis() {
    //final double priceFuture = 1.0320;
    final double priceFuture = METHOD.price(BOND_FUTURE_DERIV, CURVES);
    final double[] netBasisComputed = METHOD.netBasisFromCurves(BOND_FUTURE_DERIV, CURVES, priceFuture);
    final double[] netBasisExpected = new double[NB_BOND];
    for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) {
        final double bondPriceForward = METHOD_BOND
                .dirtyPriceFromCurves(BOND_FUTURE_DERIV.getDeliveryBasket()[loopbasket], CURVES);
        netBasisExpected[loopbasket] = bondPriceForward - (priceFuture * CONVERSION_FACTOR[loopbasket]
                + BOND_FUTURE_DERIV.getDeliveryBasket()[loopbasket].getAccruedInterest());
        assertEquals("Bond future security Discounting Method: netBasis", netBasisExpected[loopbasket],
                netBasisComputed[loopbasket], 1.0E-10);
    }
    final Min minFunction = new Min();
    final double netBasisMin = minFunction.evaluate(netBasisComputed);
    final double priceFutureFromNetBasis = METHOD.priceNetBasis(BOND_FUTURE_DERIV, CURVES, netBasisMin);
    assertEquals("Bond future security Discounting Method: netBasis", priceFuture, priceFutureFromNetBasis,
            1.0E-10);
}

From source file:com.opengamma.analytics.financial.interestrate.future.method.BondFutureDiscountingMethodTest.java

@Test
/**/*from  w  ww . ja  v a2s . co m*/
 * Tests the net basis of all bonds computed from the curves.
 */
public void netBasisAllBonds() {
    //final double priceFuture = 1.0320;
    final double priceFuture = METHOD.price(BOND_FUTURE_DERIV, CURVES);
    final double[] netBasisComputed = METHOD.netBasisAllBonds(BOND_FUTURE_DERIV, CURVES, priceFuture);
    final double[] netBasisExpected = new double[NB_BOND];
    for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) {
        final double bondPriceForward = METHOD_BOND
                .dirtyPriceFromCurves(BOND_FUTURE_DERIV.getDeliveryBasket()[loopbasket], CURVES);
        netBasisExpected[loopbasket] = bondPriceForward - (priceFuture * CONVERSION_FACTOR[loopbasket]
                + BOND_FUTURE_DERIV.getDeliveryBasket()[loopbasket].getAccruedInterest());
        assertEquals("Bond future security Discounting Method: netBasis", netBasisExpected[loopbasket],
                netBasisComputed[loopbasket], 1.0E-10);
    }
    final Min minFunction = new Min();
    final double netBasisMin = minFunction.evaluate(netBasisComputed);
    final double priceFutureFromNetBasis = METHOD.priceFromNetBasis(BOND_FUTURE_DERIV, CURVES, netBasisMin);
    assertEquals("Bond future security Discounting Method: netBasis", priceFuture, priceFutureFromNetBasis,
            1.0E-10);
}

From source file:org.apache.accumulo.core.util.Stat.java

public Stat() {
    min = new Min();
    max = new Max();
    sum = new Sum();
    mean = new Mean();
    sd = new StandardDeviation();

    stats = new StorelessUnivariateStatistic[] { min, max, sum, mean, sd };
}

From source file:org.beedraz.semantics_II.expression.number.real.double64.stat.DoubleMinBeed.java

/**
 * @post  getSource() == null;/* w w  w.  j av a  2s . c o m*/
 * @post  getDouble() == null;
 * @post  owner != null ? owner.registerAggregateElement(this);
 */
public DoubleMinBeed(AggregateBeed owner) {
    super(new Min(), owner);
}

From source file:org.matsim.contrib.common.stats.DescriptivePiStatistics.java

/**
 * Creates a new descriptive statistics object initialized with dummy
 * implementations that return {@link Double#NaN} (except
 * min/max-implementations).//from w ww  . j a v a  2  s .c om
 */
public DescriptivePiStatistics() {
    DummyPiStatistics dummyStats = new DummyPiStatistics();
    setMeanImpl(dummyStats);
    setGeometricMeanImpl(dummyStats);
    setKurtosisImpl(dummyStats);
    setMaxImpl(new StatisticsWrapper(new Max()));
    setMinImpl(new StatisticsWrapper(new Min()));
    setPercentileImpl(new DummyPiPercentile());
    setSkewnessImpl(dummyStats);
    setVarianceImpl(dummyStats);
    setSumsqImpl(dummyStats);
    setSumImpl(dummyStats);
}