bfaure / WikiPop

Chrome extension to display the view count on all Wikipedia articles
3 stars 2 forks source link

Centered moving average #3

Open bfaure opened 5 years ago

bfaure commented 5 years ago

Convert the plot simple moving average lines over to centered moving averages.

kaashan commented 5 years ago

I didn't quite understood this issue? Could you please elaborate more?

bfaure commented 5 years ago

Hey @kaashan , in the make_view_plot function of the popup_generator.js file the 7 and 50 day moving averages are currently calculated as simple moving averages (the 7 day moving average on day n is the average of the prices of the last 7 days). The goal is to implement a centered moving average so, for example, the 7-day moving average on day n is the average of views in the range [n-3, n+3] rather than [n-6,n]. The issue with this is that we'll need to either cut short our moving averages towards the end of the plot, or convert them over to simple moving averages once we run out of days pull data from. For example, if we let our number of days over which we average be M and the current true day be T, we won't be able to calculate the average for any time past (T-M/2), at this point you would need to convert over to a simple moving average for the rest of the plot. If you have any questions be sure to let me know. Thanks!