tags:

views:

32

answers:

2

Hello,

Math isn't really my thing, but what I'm trying to figure out is how to predict/estimate the next number from a dataset.

Let's say I have an array:

var values = new Array(1,4,3,5,6,10,4,15);

Does anyone know a formula in javascript that could guess the next number after 15 based off the previous values in the array.

Basically I have an array of total numbers from daily sales, each item in the array is the total for a single day. So I'd like something that could guess what tomorrow's sale might be.

+1  A: 

Based on the data you're providing, it seems you can only predict what tomorrow's sale might be by taking the average of your dataset.

If you had additional data, say, day of the week, you could take the average of all sales on Tuesdays, and then make a prediction based off of that average.

Calvin L
that's what I'm thinking about doing, it may not be 100% accurate especially if sales are on the rise or fall.
Joe
Well, like xscott says, if you can get something 100% accurate, then let me know :)
Calvin L
The point is that the more data you have, the more accurate your prediction will be. You'll never be able to get to 100% though.
Calvin L
+1  A: 

Have a look at the various moving average methods - you can choose whichever suits your application best.

casablanca
thanks for the advice, this is what I'm going with.
Joe