stratos-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pranavan135 <...@git.apache.org>
Subject [GitHub] stratos pull request: GSoC - Curve Fitting
Date Thu, 23 Jul 2015 02:45:40 GMT
Github user Pranavan135 commented on a diff in the pull request:

    https://github.com/apache/stratos/pull/382#discussion_r35286099
  
    --- Diff: extensions/cep/stratos-cep-extension/src/main/java/org/apache/stratos/cep/extension/ExponentialMovingAverage.java
---
    @@ -0,0 +1,32 @@
    +package org.apache.stratos.cep.extension;
    +
    +/**
    + * class to demonstrate how EMA works
    + */
    +public class ExponentialMovingAverage {
    +    public Double value;
    +
    +    /**
    +     * smooth the value with respect to the previous value
    +     * @param value
    +     * @return
    +     */
    +    public double getAverage(double value){
    +        if(this.value == null){
    +            this.value = value;
    +            return value;
    +        }
    +
    +        /**
    +         * calculating smoothed value
    +         */
    +        double newValue = CurveFinderWindowProcessor.ALPHA * value + (1.0 - CurveFinderWindowProcessor.ALPHA)*value;
    +        this.value = newValue;
    +
    +        return newValue;
    +    }
    +
    +    public Double getValue() {
    +        return value;
    +    }
    +}
    --- End diff --
    
    License Header Added


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message