Coder Social home page Coder Social logo

python-ema's Introduction

python-ema

for exponiential moving average calculation

here we use 'exponential moving average' to predict the next time period data value # EMA Formula:

  X(0),X(1),X(2),...,X(t-1) : data-sets total with "t" time-period-points

  EMA(1) = X(0) // initial point            -> 1 terms
  EMA(2) = EMA(1) + alpha*(X(1)-EMA(1))
            = alpha*[X(1)] + (1-alpha)*X(0)    -> 2 terms
  EMA(3) = EMA(2) + alpha*[X(2)-EMA(2)]
            = [alpha*X(1)+(1-alpha)*X(0)] + alpha*[X(2)-(alpha*X(1)+(1-alpha)*X(0))]
            = alpha*[X(2)+(1-alpha)*X(1)] + (1-alpha-alpha-alpha^2)*X(0)
            = alph*[X(2)+(1-alpha)*X(1)] + (1-alpha)^2*X(0)     -> 3 terms
       .
       .
     EMA(t) = alpha*X(t-1) + (1-alpha)*EMA(t-1) = EMA(t-1) + alpha*[X(t-1) - EMA(t-1)]
              = ...
                                1st               2nd                     3rd                            (t-1)-th
              = alpha*[ (1-alpha)^(0)*X(t-1) + (1-alpha)^(1)*X(t-2) + (1-alpha)^(2)*X(t-3) + ...+ (1-alpha)^(t-2)*X(t-(t-1)) ]
                        t-th
                + (1-alpha)^(t-1)*X(0)

     where alpha: smoothing factor, alpha=1/len(list)
           X(t-1) is observation value at time (t-1) period
           EMA(t-1) is prediction value at time (t-1) periods
           EMA(t) is prediction value at time t periods

python-ema's People

Contributors

derekjhyang avatar ncu-pdclab-sameved avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.