Monday, 7 May 2007

Bug: Variance warnings on infrequently-logged weight

A user who entered monthly log data infrequently could receive a warning from the JavaScript code, which considered a difference of $\pm 6$\% between the weight entry and the current trend value indicative of a possible error in the weight. With infrequently entered weights, the trend update falls behind, which can lead to warnings for legitimate weight entries. Now, the first thing to note here is that this is just a warning---the user can accept the entered weight value simply by clicking ``OK''. Secondly, {\em The Hacker's Diet} encourages readers to record their weight daily if possible, not at infrequent intervals, because the more frequent the weight measurements, the more closely the trend will reflect the actual smoothed weight. I modified the plausibility check for weight entries in {\tt hdiet.js} to first test for a discrepancy between the entry and the trend as before. If this indicates a possible error, we now look for a previous weight entry in this month and, if one is present, use that instead of the trend to compute the variance (since a previous weight entry can be presumed to either be in range or to have been previously confirmed as correct by the user). If no previous entry has been made for this month, we extrapolate the trend as having been evolved by a linear change from the trend at the start of the month to the weight entered, then compare the weight entered against that simulated trend value. (Reported by Lorenzo Emilitri.)

No comments: