473,761 Members | 5,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculate Moving Average

11 New Member
hello..can anyone help me. I am beginner in programming. I need to make a system that can calculate moving average.

my system process will be executed according to certain schedule such as daily, weekly or monthly based on the data in the database. The moving average will then be recorded for further process.

I want to know what is the software should be use to develop it? and can anyone show me a simple coding to calculate moving average.

please..I need help..:(
Dec 11 '07 #1
3 10922
Markus
6,050 Recognized Expert Expert
What is 'moving average'?
Dec 11 '07 #2
paeh
11 New Member
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?
Dec 12 '07 #3
GeoffreyTransom
1 New Member
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:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. include('[name of database include]');
  4.  
  5. $MALength=13; //assumes the length of the MA you want is 13
  6.  
  7. $sql1=mysql_query("select dataseries from datatable order by indexseries desc") or die ('data retrieval broke - '.mysql_error());
  8. $data=Array();
  9. while ($row=mysql_fetch_row($sql1))
  10. {
  11. $data[]=$row[0];
  12. }
  13. for ($i=0;$i<count($data);$i++)
  14. {
  15. $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);
  16. }
  17.  
  18. mysql_free_result($sql);
  19.  
  20. ?>
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.blog spot.com
Feb 18 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
13605
by: Wayne Aprato | last post by:
I've read most, if not all, of the posts on moving average and still can't find a simple solution to my problem (if a simple solution exists!) I have a table with 2 fields: Hours and Injuries. I have a query based on this table which shows these 2 fields and calculates a third field: Frequency Rate, based on a formula which uses the Hours and Injuries fields. Is there a simple way of A: using yet another calculated field in the query...
2
3650
by: Steve | last post by:
Hi all How would I find out the average date when given a bunch of dates? For example, I want to find the average length in time from the following dates: ---------------------------------------------------- Start Date End Date 01/01/2004 12:50pm 02/01/2004 18:40pm 02/01/2004 13:40pm 02/01/2004 13:57pm 02/01/2004 14:30pm 02/01/2004 19:50pm
1
21107
by: HEMH6 | last post by:
Weihted Average Write a C program to calculate and print the weighted average of a list of N floating point number, using the formula Xave = F1X1 + F2X2+...+ FnXn where the F's are fractional weighting factors, i.e. 0<=F1<1, and F1+F2+...+Fn=1
4
6539
by: gaga | last post by:
hi guys, a part of my program requires me to calculate an average of items that are sold. the easiest way to do that would be writing a function, but im having trouble making up the parameters. if you can point me which elements to use when performing such a task, i would really appreciate it. thanks
1
7300
by: Sedigh | last post by:
Hi Everybody, I need to write a macro on my Excel sheet to calculate the average of cells for me. This is the code I have written but the average function is not working. Can you please let me know how can I use the Average function in my code. Thanks alot Sub Macro1() Ncol = 1 nrowColumn2 = 1 i = 1 Do Until IsEmpty(Worksheets(1).Cells(i, 1))
7
10259
by: jamesnkk | last post by:
Hi, Although this question may not directly link to Access, but I think it a common question to those developer.so hope you could suggest a solution. How do I get the average cost for Item sold, so I could calculate the Profit.- Same Product item could bought from different suppliers, different suppliers have different cost price or buying price. There is only 1 standard selling price, In order to calculate the profit, I would take...
0
4641
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars (double) Sales Units (double) Promo (Text) -- is null or "X" AvgWklyDollars (double) AvgWklyUnits (double) I have a vba module which I thought would work, but it doesn't. I think the problem is an embedded SQL Totals Top 8 query, which doesn't...
3
4873
by: hanie | last post by:
a student wants to know his grade average for the semester. the grades are give in letter grades with numeric equivalents. develop a solution to calculate a grade average given the letter grades(the grade average is is figured per unit of credit!) A=4.0 B=3.0 C=2.0 D=1.0 F=0.0 use a trip value to stop the processing of the loop and case structure to find the grade points
1
7635
by: Michel | last post by:
Hello, I need to calculate moving averages of weekly data during the last year. After some search, I believe that the best approach will be to get a dataset from the SQL Server database, browse the records and, using an algorithm, calculate the moving average. There is an article on the "Code Project" website entitled "A Simple Moving Average Algorithm" but honnestly I have been unable to
0
9522
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9948
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9765
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8770
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7327
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6603
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3446
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.