Calculate average

Discussion in 'PHP' started by look4guna, Jan 18, 2011.

  1. #1
    Hi Friends,

    I want to calculate weekly,monthly,yearly averages based on daily averages. for ex:
    Daily avg. can be calculated by adding (previous avg+today value)/2. using this daily avg i want to calculate above said averages. anybody have a formula for this?

    anybody can help me to get out of this problem?
     
    look4guna, Jan 18, 2011 IP
  2. plog

    plog Peon

    Messages:
    298
    Likes Received:
    11
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Your daily average calculation is wrong. Suppose Sunday-Friday you sell 3 units each day. Obviously, on Friday, the average is 3 units a day. On Saturday you sell 9, using your method your daily average now jumps to 6 units a day ((Average on Friday + Saturday's total)/2). Which is wrong--in 7 days you sold 27 total units (6 days of 3 and 1 day of 9), which makes your daily average around 3.85 (units/days).

    You can't use an average to calculate an average. The correct way to calculate any timeframe is to take the sum of the actual data and divide it by the timeframe.
     
    plog, Jan 18, 2011 IP
  3. look4guna

    look4guna Active Member

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Thanks plog, am working on your suggestion...
     
    look4guna, Jan 19, 2011 IP