SOLUTION: Hi, I am in need of some help regarding my prediction of a number based from a given sequence of numbers. For example 15 14 15 14, by inspection I can expect 15 next, but I am tryi

Algebra.Com
Question 1086920: Hi, I am in need of some help regarding my prediction of a number based from a given sequence of numbers. For example 15 14 15 14, by inspection I can expect 15 next, but I am trying to write a computer program to find it. I could simply find the nth term, and find the next number, but what if the common difference isn't static? For example what if the sequence is 15 11 15 10 15 9 15 8 15, I don't understand how to find the next term in this case.
My application of this is for predicting a players input lag, and extrapolate their position, so that their lag doesn't effect other players ability to target the player lagging.
Furthermore, other than predicting their next amount of lag, I would also need to predict their movement, given by x y z coordinates, and velocity, any help with the movement prediction would be appreciated also, but top priority would be predicting their input lag first!
Example of prediction movement could be
Vector calculatePosition(double time, Vector startPosition, Vector velocity, Vector accel = 0) {
return startPosition + (velocity * time) + (0.5 * accel * pow(time, 2));
}
Any help would really go far in helping me, thanks in advance!

Answer by jim_thompson5910(35256)   (Show Source): You can put this solution on YOUR website!
Sequence = {15,14,15,14,...}
as you stated, the pattern is alternating so the next term appears to be 15
that's of course if the pattern keeps repeating

If the pattern keeps alternating forever, then the sequence rule could be boiled down to
a_n = 15 if n is odd
a_n = 14 if n is even
essentially a piecewise definition. The variable n must be a positive integer.
The value n starts at n = 1

-------------------------------------------------------------------------------

Sequence = {15,11,15,10,15,9,15,8,15,...}
The pattern here isn't obvious. Notice how the 15's keep repeating. Specifically they repeat in the 1st, 3rd, 5th, etc slots. So every odd slot we have the number 15. The even slots have the sub-sequence {11, 10, 9, 8, ...} which is clearly an arithmetic sequence
Rule:
a_n = 15 if n is odd
a_n = 13-n if n is even
n is a positive integer
again we have a piecewise definition to piece together two sequences in alternating fashion
The value n starts at n = 1; n is an integer

Like the previous sequence, the rule only works if the pattern keeps repeating (the 15s repeating in the odd slots; the countdown in the even slots)
-------------------------------------------------------------------------------

While I did find rules for both sequences you provided, it's not always possible to find sequence formulas based on a given pattern. The problem boils down to two factors

A) The terms given may not repeat in the same fashion as you extrapolate the sequence further out. In other words, what happens today may not happen tomorrow. An oft used saying in finance is "past performance doesn't guarantee future results". So while it's clear that {11,10,9,8,...} decreases by 1 each time, there is a possibility that the next term isn't 7 based on reality not being completely conforming to nice formulas. The fact that your data may be random is also a problem. I honestly don't know enough about the type of data you're dealing with to be 100% sure about how random things are.

B) Even if there is a pattern, it's not always clear what it is. Arithmetic and geometric are just two of many other types of sequences. Other examples include the sequence of squares {1, 4, 9, 16, 25, ...} and the sequence of cubes {1, 8, 27, 64, 125, ...}. You get the idea. Identifying the type of sequence will just require a trained eye. I'm not sure how else to explain it. To get the computer to detect the pattern type, the only thing I can think of is training it with neural networks (so using some kind of AI). But my knowledge in that area is very limited.

Side Note: The On-Line Encyclopedia of Integer Sequences (OEIS) is exactly as it sounds: it's an encyclopedia of all sorts of integer sequences. You can look up sequences by name or type in a few terms of a sequence into the search bar to see if the site can find a match. Eg: if you type in something like "1,4,9,16,25" without quotes then it should return as one of the matches "the list of perfect squares". This isn't really done in a math formula kind of way. It's more of a search algorithm.

RELATED QUESTIONS

The decimal system we use is based on the number 10. For example, the number 132 is... (answered by Alan3354)
HELP: Is my professor unreasonable or am I totally confused? I answered the other 6... (answered by stanbon)
I am working on Linear Equation and Inequalities I have to identify solutions to a two (answered by addingup,MathTherapy)
How can you know how many number there are in a given sequence? For example from 1 to... (answered by jsmallt9)
I am investigating a pattern, our topic is linear patterns. The pattern is a square like... (answered by josgarithmetic)
hi i need some help with graphing inequalities i understand some of it, but not all of... (answered by Edwin McCravy)
Hi! I need some help. Sorry for the trouble. My question is: A number is four times... (answered by ewatrrr)
Based on my previous questions and the answer provided: ``Hello I have a question... (answered by Mathtut)
Hi! I have to write a linear function of the monthly price of a cell phone plan, with x... (answered by ankor@dixie-net.com)