Return-Path: X-Original-To: apmail-stratos-dev-archive@minotaur.apache.org Delivered-To: apmail-stratos-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4E13D183C5 for ; Thu, 23 Jul 2015 02:45:41 +0000 (UTC) Received: (qmail 36408 invoked by uid 500); 23 Jul 2015 02:45:41 -0000 Delivered-To: apmail-stratos-dev-archive@stratos.apache.org Received: (qmail 36354 invoked by uid 500); 23 Jul 2015 02:45:41 -0000 Mailing-List: contact dev-help@stratos.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stratos.apache.org Delivered-To: mailing list dev@stratos.apache.org Received: (qmail 36344 invoked by uid 99); 23 Jul 2015 02:45:40 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jul 2015 02:45:40 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B000AE17FC; Thu, 23 Jul 2015 02:45:40 +0000 (UTC) From: Pranavan135 To: dev@stratos.apache.org Reply-To: dev@stratos.apache.org References: In-Reply-To: Subject: [GitHub] stratos pull request: GSoC - Curve Fitting Content-Type: text/plain Message-Id: <20150723024540.B000AE17FC@git1-us-west.apache.org> Date: Thu, 23 Jul 2015 02:45:40 +0000 (UTC) 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. ---