Search in sources :

Example 1 with BasicStatistics

use of jcog.meter.func.BasicStatistics in project narchy by automenta.

the class MetricsTest method testSummaryStatistics.

// @Test public void testMeterDerivative() {
// 
// TemporalMetrics<Integer> tm = new TemporalMetrics<>(3);
// tm.add(timeDoubler);
// tm.add(new FirstOrderDifference(tm, timeDoubler.signalID(0)));
// 
// assertEquals(3, tm.getSignals().size());
// 
// tm.update(0.0);
// tm.update(1.0);
// 
// //check the '1' column ('x')
// assertEquals(0, tm.getData(1)[0]);
// assertEquals(2, tm.getData(1)[1]);
// 
// tm.update(2.0);
// 
// 
// 
// //check the '2' column (first order diff)
// assertEquals(null, tm.getData(2)[0]);
// assertEquals(2.0, tm.getData(2)[1]);
// 
// 
// }
@Disabled
@Test
public void testSummaryStatistics() {
    TemporalMetrics tm = new TemporalMetrics(10);
    tm.add(new BasicStatistics(tm, tm.getSignalIDs()[0]));
    for (int i = 0; i < 10; i++) {
        tm.update(0.1 * i);
    }
    // noinspection OverlyComplexAnonymousInnerClass
    PrintStream sb = new PrintStream(System.out) {

        int line;

        @Override
        public void println(String x) {
            String eq = null;
            switch(line++) {
                case 0:
                    eq = "\"key\",\"key.mean\",\"key.stdev\"";
                    break;
                case 1:
                    eq = "0,0,0";
                    break;
                case 3:
                    eq = "0.2,0.1,0.1";
                    break;
            }
            if (eq != null) {
                assertEquals(eq, x);
            }
        }
    };
    tm.printCSV(sb);
}
Also used : PrintStream(java.io.PrintStream) BasicStatistics(jcog.meter.func.BasicStatistics) TemporalMetrics(jcog.meter.TemporalMetrics) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Aggregations

PrintStream (java.io.PrintStream)1 TemporalMetrics (jcog.meter.TemporalMetrics)1 BasicStatistics (jcog.meter.func.BasicStatistics)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1