Php Code Exponential Moving Average - Php

How to calculate exponential moving average using php code?

Snippet Code


  
Rate this page :
  [ 0 votes]

This php code can be used to calculate the exponential moving average.

<?php function esma($in) { $out[0] = $in[0]; for($i=1; $i<sizeof($in); $i++) { $out[$i] = $out[$i-1] + 0.1 * ($in[$i] - $out[$i-1]); } return $out; } $in=array(2,3,4,20.45,22,56); $arr=esma($in); print_r($arr); ?>

Tags


Ask Questions

Ask Question