moving average is the process that will be executed according to certain schedule such as daily, weekly or monthly based on the data in the database. For your information, I plan to use MySQL database server. It can be produce by graph,chart or table.
Actually, I want to develop web based communicable disease reporting system
(Surveillance system for Flu and Entrovirus).
I don't know what kind of software to develop it. can I use PHP?
hello Paeh.
The easiest way is to retrieve the data from MySQL into, say, PHP, then use Array formulae to operate on it.
So if for example the series you want to average is in table
datatable and is called
dataseries and is stored by
indexseries, then do the following:
-
<?php
-
-
include('[name of database include]');
-
-
$MALength=13; //assumes the length of the MA you want is 13
-
-
$sql1=mysql_query("select dataseries from datatable order by indexseries desc") or die ('data retrieval broke - '.mysql_error());
-
$data=Array();
-
while ($row=mysql_fetch_row($sql1))
-
{
-
$data[]=$row[0];
-
}
-
for ($i=0;$i<count($data);$i++)
-
{
-
$MovAverage[$i]=round(array_sum(array_slice($data,max($i-$MALength+1,0),$MALength))/count(array_slice($data,max($i-$MALength+1,0),$MALength)),4);
-
}
-
-
mysql_free_result($sql);
-
-
?>
While this might not be the most elegant method (I am sure there are purists who would be horrified), the end result ought to be a vector variable $MovAverage which contains the moving average you desire.
Given that I am on my fourth glass of a rather cheeky Rosé, there are no doubt some typos in the code... but nothing too drastic. The first thing to look for is missing line ends... I am diabolical at those.
Hope this helps...
GT
France
http://marketrant.blogspot.com