Package org.apache.commons.math.stat.descriptive

Examples of org.apache.commons.math.stat.descriptive.DescriptiveStatistics


        weightedValues[i] = measurement.value().magnitude() / measurement.weight();
        i++;
      }
      Percentile percentile = new Percentile();
      percentile.setData(weightedValues);
      DescriptiveStatistics descriptiveStatistics = new DescriptiveStatistics(weightedValues);
      String unit = Iterables.getOnlyElement(units);
      stdout.printf(
          "  %s%s: min=%.2f, 1st qu.=%.2f, median=%.2f, mean=%.2f, 3rd qu.=%.2f, max=%.2f%n",
          entry.getKey(), unit.isEmpty() ? "" : "(" + unit + ")",
          descriptiveStatistics.getMin(), percentile.evaluate(25),
          percentile.evaluate(50), descriptiveStatistics.getMean(),
          percentile.evaluate(75), descriptiveStatistics.getMax());
    }

    instrumentSpecs.add(trial.instrumentSpec());
    Scenario scenario = trial.scenario();
    vmSpecs.add(scenario.vmSpec());
View Full Code Here


                new int[]{7, 0, 0, 0}, //Max INdex Per Tensor
                20, 2, true);
        rp.reset(-3806751651286565680L);
        System.out.println("Random Seed = " + rp.getSeed());
        System.out.println("NM Seed = " + CC.getNameManager().getSeed());
        DescriptiveStatistics timeStats = new DescriptiveStatistics();
        DescriptiveStatistics trysStats = new DescriptiveStatistics();
        int count = 0;
        while (++count < 5000) {
            CC.resetTensorNames();
            Product from = rp.next();
            Product target = from.clone();

            long start = System.nanoTime();
            ProductsBijectionsPort port = new ProductsBijectionsPort(from.getContent(), target.getContent());

            int[] bijection;
            boolean good = false;
            int trys = 0;
            OUTER:
            while (trys++ < 5000 && (bijection = port.take()) != null) {
                for (int i = 0; i < bijection.length; ++i)
                    if (bijection[i] != i)
                        continue OUTER;
                good = true;
                break;
            }

            double millis = 1E-6 * (System.nanoTime() - start);
            timeStats.addValue(millis);
            trysStats.addValue(trys);

            if (!good)
                throw new RuntimeException();
        }
        System.out.println(timeStats);
View Full Code Here

//        Product t = rp.next();
//        ContractionsGraphDrawer.drawToPngFile(t, "/home/stas/Projects/Durty/", "Huge1");


        DescriptiveStatistics timeStats = new DescriptiveStatistics();
        DescriptiveStatistics trysStats = new DescriptiveStatistics();
        int count = -1;
        while (++count < 100) {
            CC.resetTensorNames();
            Product from = rp.next();
            Product target = from.clone();

            long start = System.nanoTime();
            Tensor[] dataFrom = from.getContent().getDataCopy();
            Tensor[] dataTarget = target.getContent().getDataCopy();
//             if (count == 6)
//                ContractionsGraphDrawer.drawToPngFile(from, "/home/stas/Projects/Durty/", "Huge6");
            if (count == 24)
                ContractionsGraphDrawer.drawToPngFile(from, "/home/stas/Projects/Durty/", "Huge24");
            if (count == 30)
                ContractionsGraphDrawer.drawToPngFile(from, "/home/stas/Projects/Durty/", "Huge30");
            ProductsBijectionsPort port = new ProductsBijectionsPort(from.getContent(), target.getContent());

//            List<int[]> bijections = new ArrayList<>();
            int[] bijection;
            boolean good = false;
            int trys = 0;
            OUTER:
            while (trys++ < 5000 && (bijection = port.take()) != null)
//                System.out.println(Arrays.toString(bijection));
//                bijections.add(bijection.clone());
                if (IndexMappings.createBijectiveProductPort(dataFrom, dataTo(dataTarget, bijection), false).take() != null) {
                    good = true;
                    System.out.println(count + "  " + trys);
                    break;
                }
//            if (trys == 3169) {
//                ContractionsGraphDrawer.drawToPngFile(from, "/home/stas/Projects/Durty/", "Worst");
//                for (int[] b : bijections)
//                    System.out.println(Arrays.toString(b));
//            }
            double millis = 1E-6 * (System.nanoTime() - start);
            timeStats.addValue(millis);
            trysStats.addValue(trys);

            if (!good)
                throw new RuntimeException();
        }
        System.out.println(timeStats);
View Full Code Here

                new int[]{7, 0, 0, 0}, //Max INdex Per Tensor
                20, 2, true);
        rp.reset(-3806751651286565680L);
        System.out.println("Random Seed = " + rp.getSeed());
        System.out.println("NM Seed = " + CC.getNameManager().getSeed());
        DescriptiveStatistics timeStats = new DescriptiveStatistics();
        DescriptiveStatistics trysStats = new DescriptiveStatistics();
        int count = 0;
        while (++count < 5000) {
            CC.resetTensorNames();
            Product from = rp.next();
            Product target = from.clone();

            long start = System.nanoTime();
            ProductsBijectionsPort port = new ProductsBijectionsPort(from.getContent(), target.getContent());
            Tensor[] dataFrom = from.getContent().getDataCopy();
            Tensor[] dataTarget = target.getContent().getDataCopy();
//            List<int[]> bijections = new ArrayList<>();
            int[] bijection;
            boolean good = false;
            int trys = 0;
            OUTER:
            while (trys++ < 5000 && (bijection = port.take()) != null) {
//                bijections.add(bijection.clone());
                if (IndexMappings.createBijectiveProductPort(dataFrom, dataTo(dataTarget, bijection), false).take() != null) {
                    good = true;
                    break;
                }
            }
//            if (trys == 3169) {
//                ContractionsGraphDrawer.drawToPngFile(from, "/home/stas/Projects/Durty/", "Worst");
//                for (int[] b : bijections)
//                    System.out.println(Arrays.toString(b));
//            }
            double millis = 1E-6 * (System.nanoTime() - start);
            timeStats.addValue(millis);
            trysStats.addValue(trys);

            if (!good)
                throw new RuntimeException();
        }
        System.out.println(timeStats);
View Full Code Here

                // Create the repository
                RepositoryImpl repository = createRepository(dir, xml);
                try {
                    // Run the test
                    DescriptiveStatistics statistics = runTest(test, repository);
                    if (statistics.getN() > 0) {
                        writeReport(test.toString(), name, statistics);
                    }
                } finally {
                    repository.shutdown();
                }
View Full Code Here

    }

    private DescriptiveStatistics runTest(
            AbstractTest test, Repository repository)
            throws Exception {
        DescriptiveStatistics statistics = new DescriptiveStatistics();

        test.setUp(repository, credentials);
        try {
            // Run a few iterations to warm up the system
            long warmupEnd = System.currentTimeMillis() + warmup * 1000;
            while (System.currentTimeMillis() < warmupEnd) {
                test.execute();
            }

            // Run test iterations, and capture the execution times
            long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
            while (System.currentTimeMillis() < runtimeEnd) {
                statistics.addValue(test.execute());
            }
        } finally {
            test.tearDown();
        }

View Full Code Here

            RepositoryImpl repository;
            try {
                repository = createRepository(microKernel);

                // Run the test
                DescriptiveStatistics statistics = runTest(test, repository);
                if (statistics.getN() > 0) {
                    writeReport(test.toString(), name, microKernel, statistics);
                }
            } catch (RepositoryException re) {
                re.printStackTrace();
            } catch (Exception e) {
View Full Code Here

        }
    }

    private DescriptiveStatistics runTest(AbstractTest test,
            Repository repository) throws Exception {
        DescriptiveStatistics statistics = new DescriptiveStatistics();

        test.setUp(repository, credentials);
        try {
            // Run a few iterations to warm up the system
            long warmupEnd = System.currentTimeMillis() + warmup * 1000;
            while (System.currentTimeMillis() < warmupEnd) {
                test.execute();
            }

            // Run test iterations, and capture the execution times
            long runtimeEnd = System.currentTimeMillis() + runtime * 1000;
            while (System.currentTimeMillis() < runtimeEnd) {
                statistics.addValue(test.execute());
            }
        } finally {
            test.tearDown();
        }

View Full Code Here

    /**
     * Test StorelessDescriptiveStatistics
     */
    public void testStoredUnivariateImpl() throws Exception {

        DescriptiveStatistics u = DescriptiveStatistics.newInstance();
       
        loadStats("data/PiDigits.txt", u);
        assertEquals("PiDigits: std", std, u.getStandardDeviation(), .0000000000001);
        assertEquals("PiDigits: mean", mean, u.getMean(), .0000000000001);
       
        loadStats("data/Mavro.txt", u);
        assertEquals("Mavro: std", std, u.getStandardDeviation(), .00000000000001);
        assertEquals("Mavro: mean", mean, u.getMean(), .00000000000001);       
       
        //loadStats("data/Michelso.txt");
        //assertEquals("Michelso: std", std, u.getStandardDeviation(), .00000000000001);
        //assertEquals("Michelso: mean", mean, u.getMean(), .00000000000001);  

        loadStats("data/NumAcc1.txt", u);
        assertEquals("NumAcc1: std", std, u.getStandardDeviation(), .00000000000001);
        assertEquals("NumAcc1: mean", mean, u.getMean(), .00000000000001);
       
        //loadStats("data/NumAcc2.txt");
        //assertEquals("NumAcc2: std", std, u.getStandardDeviation(), .000000001);
        //assertEquals("NumAcc2: mean", mean, u.getMean(), .00000000000001);
    }
View Full Code Here

     * @param file
     * @param statistical summary
     */
    private void loadStats(String resource, Object u) throws Exception {
       
        DescriptiveStatistics d = null;
        SummaryStatistics s = null;
        if (u instanceof DescriptiveStatistics) {
            d = (DescriptiveStatistics) u;
        } else {
            s = (SummaryStatistics) u;
        }
        u.getClass().getDeclaredMethod(
                "clear", new Class[]{}).invoke(u, new Object[]{});
        mean = Double.NaN;
        std = Double.NaN;
       
        BufferedReader in =
            new BufferedReader(
                    new InputStreamReader(
                            getClass().getResourceAsStream(resource)));
       
        String line = null;
       
        for (int j = 0; j < 60; j++) {
            line = in.readLine();
            if (j == 40) {
                mean =
                    Double.parseDouble(
                            line.substring(line.lastIndexOf(":") + 1).trim());
            }
            if (j == 41) {
                std =
                    Double.parseDouble(
                            line.substring(line.lastIndexOf(":") + 1).trim());
            }
        }
       
        line = in.readLine();
       
        while (line != null) {
            if (d != null) {
                d.addValue(Double.parseDouble(line.trim()));
            else {
                s.addValue(Double.parseDouble(line.trim()));
            }
            line = in.readLine();
        }
View Full Code Here

TOP

Related Classes of org.apache.commons.math.stat.descriptive.DescriptiveStatistics

Copyright © 2018 www.massapicom. 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.