Package com.inadco.hbl.math.aggregators

Examples of com.inadco.hbl.math.aggregators.OnlineCannyRateSummarizer


            k = Double.parseDouble(props.getProperty("k"));

        Validate.isTrue(props.containsKey("dt"), "dt parameter is required for exp avg summarizer");
        dt = Double.parseDouble(props.getProperty("dt"));

        return new OnlineCannyRateSummarizer(dt, m, k);

    }
View Full Code Here


        Assert.assertTrue(Math.abs(sum2.getValue() - compl1.getValue()) < PREC);
    }

    @Test(enabled = false)
    public void testCannyRate1() {
        OnlineCannyRateSummarizer sum = new OnlineCannyRateSummarizer(5d), sum1 = new OnlineCannyRateSummarizer(5d), sum2 =
            new OnlineCannyRateSummarizer(5d);

        sum.update(1, 1);
        sum1.update(1, 1);
        sum.update(2, 2);
        sum1.update(2, 2);

        sum.update(4, 4);
        sum2.update(4, 4);
//        sum1.update(0, 4); // connect sum1 to sum2 interval -- needed for
                           // complement to work.. well, at least one of the scenarios.

        sum.update(5, 5);
        sum2.update(5, 5);

        OnlineCannyRateSummarizer combined = IOUtil.tryClone(sum1);
        combined.combine(sum2);
        OnlineCannyRateSummarizer compl1 = IOUtil.tryClone(sum);
        compl1.complement(sum1, false);
        OnlineCannyRateSummarizer compl2 = IOUtil.tryClone(sum);
        compl2.complement(sum2, false);

        Assert.assertTrue(Math.abs(sum.getValue() - combined.getValue()) < PREC);
        Assert.assertTrue(Math.abs(sum2.getValue() - compl1.getValue()) < PREC);
        Assert.assertTrue(Math.abs(sum1.getValue() - compl2.getValue()) < PREC);
    }
View Full Code Here

     * @param dt
     */
    public FCannyRateSum(String name, int ordinal, double dt) {
        super(name, ordinal);
        // this.dt = dt;
        sumBuf = new OnlineCannyRateSummarizer(dt);
        sumBuf1 = new OnlineCannyRateSummarizer(dt);
    }
View Full Code Here

        double x = ((Number) fact).doubleValue();

        try {

            OnlineCannyRateSummarizer s = super.extractState(result, sumBuf);
            if (s == null) {
                sumBuf.reset();
                s = sumBuf;
            }
            s.update(x, sample.getTime());

            super.saveState(result, sumBuf);
        } catch (IOException exc) {
            // should not happen .
            // otherwise, probably a bad practice.
View Full Code Here

    }

    @Override
    public void merge(Builder accumulator, Aggregation source, SliceOperation operation) {
        try {
            OnlineCannyRateSummarizer s1 = super.extractState(accumulator, sumBuf);
            OnlineCannyRateSummarizer s2 = super.extractState(source, sumBuf1);

            switch (operation) {
            case ADD:
                if (s1 != null && s2 != null)
                    s1.combine(s2);
View Full Code Here

            /*
             * since we don't have control over result object lifecycle in this
             * case, we'd rather create a new summarizer for each incoming
             * request.
             */
            return extractState(source, new OnlineCannyRateSummarizer());
        } catch (IOException exc) {
            throw new RuntimeException(exc);
        }

    }
View Full Code Here

TOP

Related Classes of com.inadco.hbl.math.aggregators.OnlineCannyRateSummarizer

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.