List of usage examples for org.apache.commons.math.stat.descriptive.rank Min evaluate
@Override public double evaluate(final double[] values)
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)); }/*from www . j av a 2 s . c o m*/ }
From source file:com.opengamma.analytics.financial.interestrate.future.provider.BondFuturesSecurityDiscountingMethodTest.java
@Test /**/*from w ww. ja va 2 s. 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.method.BondFutureSecurityDiscountingMethodTest.java
@Test /**/*from www . j a va2s . com*/ * 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.provider.BondFutureDiscountingMethodTest.java
@Test /**/*www.jav a 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.BondFutureDiscountingMethodTest.java
@Test /**/*from w ww. java 2 s . 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.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); }