Search in sources :

Example 1 with SumOfLogs

use of org.apache.commons.math3.stat.descriptive.summary.SumOfLogs in project uPortal by Jasig.

the class JpaStatisticalSummaryTest method testSummaryStatisticsJson.

// @Test
// public void testJpaStatisticalSummary() {
// final long id = this.executeInTransaction(new Callable<Long>() {
// @Override
// public Long call() throws Exception {
// final JpaStatisticalSummary jpaStatisticalSummary = new
// JpaStatisticalSummary();
// 
// final Random r = new Random(0);
// for (int i = 0; i < 10; i++) {
// final int nextInt = r.nextInt(100000000);
// jpaStatisticalSummary.addValue(nextInt);
// }
// 
// getEntityManager().persist(jpaStatisticalSummary);
// 
// System.out.println(jpaStatisticalSummary);
// 
// return jpaStatisticalSummary.getStatSummaryId();
// }
// });
// 
// System.out.println(id);
// 
// this.executeInTransaction(new CallableWithoutResult() {
// @Override
// protected void callWithoutResult() {
// final JpaStatisticalSummary jpaStatisticalSummary =
// getEntityManager().find(JpaStatisticalSummary.class, id);
// 
// System.out.println(jpaStatisticalSummary);
// }
// });
// }
@Ignore
@Test
public void testSummaryStatisticsJson() throws Exception {
    final SecondMoment secondMoment = new SecondMoment();
    final Sum sum = new Sum();
    final SumOfSquares sumsq = new SumOfSquares();
    final Min min = new Min();
    final Max max = new Max();
    final SumOfLogs sumLog = new SumOfLogs();
    final Random r = new Random(0);
    for (int i = 0; i < 10; i++) {
        final int nextInt = r.nextInt(100000000);
        secondMoment.increment(nextInt);
        sum.increment(nextInt);
        sumsq.increment(nextInt);
        min.increment(nextInt);
        max.increment(nextInt);
        sumLog.increment(nextInt);
    }
    testStorelessUnivariateStatistic(secondMoment, 7.513432791665536E15);
    testStorelessUnivariateStatistic(sum, 6.01312177E8);
    testStorelessUnivariateStatistic(sumsq, 4.3671066212513456E16);
    testStorelessUnivariateStatistic(min, 2116447.0);
    testStorelessUnivariateStatistic(max, 8.5505948E7);
    testStorelessUnivariateStatistic(sumLog, 175.91713800250577);
}
Also used : SumOfLogs(org.apache.commons.math3.stat.descriptive.summary.SumOfLogs) Min(org.apache.commons.math3.stat.descriptive.rank.Min) SumOfSquares(org.apache.commons.math3.stat.descriptive.summary.SumOfSquares) Random(java.util.Random) Max(org.apache.commons.math3.stat.descriptive.rank.Max) Sum(org.apache.commons.math3.stat.descriptive.summary.Sum) SecondMoment(org.apache.commons.math3.stat.descriptive.moment.SecondMoment) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseAggrEventsJpaDaoTest(org.apereo.portal.test.BaseAggrEventsJpaDaoTest)

Aggregations

Random (java.util.Random)1 SecondMoment (org.apache.commons.math3.stat.descriptive.moment.SecondMoment)1 Max (org.apache.commons.math3.stat.descriptive.rank.Max)1 Min (org.apache.commons.math3.stat.descriptive.rank.Min)1 Sum (org.apache.commons.math3.stat.descriptive.summary.Sum)1 SumOfLogs (org.apache.commons.math3.stat.descriptive.summary.SumOfLogs)1 SumOfSquares (org.apache.commons.math3.stat.descriptive.summary.SumOfSquares)1 BaseAggrEventsJpaDaoTest (org.apereo.portal.test.BaseAggrEventsJpaDaoTest)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1