I'm writing a little tool that counts the downloads of an app. I save every download with a timestamp.
What algorithm (php and mysql) is normally used开发者_开发技巧 for predicting eg todays downloads?
You could do Regression Analysis to predict the number of downloads on a given day. This image from Wikipedia shows some sample data points and the best-fit line. In case of downloads, the X axis could represents days, and Y axis could represent the number of downloads. Keeping that assumption, one would see that the number of downloads are going up each day on average.
Here's a good article explaining Linear Regression and IBM has written two articles on how to implement Simple Linear Regression with PHP (1, 2).
Also check out these other threads:
- Occurrence prediction
- Predictional Logic in Programming?
- Predict next event occurrence, based on past occurrences
The term you want is "extrapolation", there are some equations and further details described here: http://en.wikipedia.org/wiki/Extrapolation
In principle you need to pick an equation that matches your expected trend (linear, exponential etc) then you use the current data to find the parameters that best fit that equation to your data. Something like R-squared is a simple measure of best fit.
Once you've done a best-fit you can use the resulting equation parameters to extrapolate future data.
精彩评论