We don't bite newbies here... much | |
PerlMonks |
Re: Data averages by time of dayby Abigail-II (Bishop) |
on Feb 26, 2004 at 15:39 UTC ( [id://332020]=note: print w/replies, xml ) | Need Help?? |
It's not clear to me what you really want. Perhaps you want
"averages" of certain pre-picked points in time. Say, the
average of 7AM, 11AM, 3PM, 7PM and 12midnight. Or maybe you
you a way where you can pick a time, plug it into a formulae,
and the average rolls out of it.
You might want to interpolate, but there are many ways of interpolating. A piece-wise linear interpolation of successive datapoints is the simplest, but it's also crude. And even then there are decisions to be made. Suppose you want the average level on 11AM, and you have datapoints on 9:15AM on day 1, 12:30 PM on day1, 8:30AM on day2 and 11:55AM on day2. You can do interpolation between the 9:15AM and 11:55AM times - they are the times closest to 11:00AM, but they are from different days. You can also first interpolate the two points of the first day, then interpolate the two points on the second day, then average. But is linear interpolation appropriate? Many biometric measurements are supposed to vary during the day, perhaps according to a sinal wave. You can then do a better approximation of the value by taking this into account. You can even increase accuracy by doing interpolation (be it linear or something else) by including more points. But not blindly, it can also decrease the accuracy, specially if you use the "wrong" interpolation. Alternatively, you can make a "best fit" curve using all the measurements of a day, or even all the measurements. With a best fit curve, you typically first decide what form the curve should have (a line, a parabole, a sinal wave, etc), and then from all the possible curves of that form, you find the one that minimizes some distance from your measure point. An often used distance is the sum of the squares of the distances of all the measured points to the curve. There are standard techniques for this. 4:30AM (when I get up days I go to the gym)Man, that can't be healthy. 4:30AM is a time to say goodnight on IRC, write a final post on Perlmonks, save your days work in CVS, check to see if there's a tape in your backup unit, and to hide in your bed for that big hot thing that's about to rise the skies. Abigail
In Section
Seekers of Perl Wisdom
|
|