If it is a strict pattern, something like
1 4 9 16 25 36
(the square of each incrementing number) then you could hard code a function that would determine exactly the next number.
If your data is somewhat fuzzy (not exact) such as what time the train will reach the next station given the time it reached the previous station then
Fuzzy Logic[
^] would be the way to go.
The basic idea of fuzzy logic is that you get a series of inputs (perhaps from the same variable, and perhaps from different variables) and you apply some fuzzy logic to predict the next value or some value in the future.
If you have or can get a copy of matlab i would
strongly recommend reading the matlab help manual about Fuzzy Inference Systems and work through its examples.
The implementation will be slightly different in code, but it will really help your understanding.
I will give a rough explanation of what they are tho.
I will not explain the details of techniques such as fuzzification and defuzzification, if you don't read about them in matlab then it will just confuse you.
In the case of your train example:
The train travels from station A to B then to C
The base time for the train to get from A to B is 25min and to get from B to C is 35min.
Then there are some factors that affect it.
During busy times the train spends longer at each station.
When it is raining the train cannot travel as fast.
Now we convert these into the inputs:
1. Starting station
2. Finishing station
2. Time of day (this is for how busy it is. You may include day of week as an input as well)
3. How wet it is
Each of these inputs takes a value in a specified domain and range, generally 0.0-1.0
Next we generate a function that will map each input to a weight over its range.
For "How wet it is", I would make the domain 0.0 (dry) to 1.0 (pouring rain or hail) and the range 0.0 (no delay) to 1.0 (delayed a lot)
This step can be skipped if you want, this is more for ease of use by end users.
next we create
linguistic variables[
^] for each input.
This is basically a word or phrase that represents a value of a specific variable. I have already done this subconsciously in the previous step to help the explanation.
In the case of "How wet it is" again, we might define:
dry = 0.0
drizzle = 0.1
mist = 0.2
moderate = 0.4
heavy = 0.8
hail = 1.0
So that the user would select 1 of those words as the input to the variable "How wet it is", and the same would go for the other variables.
Now that we have the domain (input) of the variable we need to get the range (output) which defines a function that relates the input to the output.
For the case of "How wet it is" you want something with an incline, like
linear
,
exponential
or
logarithmic
. But it can be anything you want.
I would say that exponential would be a good choice in this particular case.
Finally, you need to combine the result from evaluating the function of all your inputs to produce a final answer.
You will likely need to weight each input individually based on how much it will effect the time of arrival.
The Start/Finish station inputs will take the station name as a linguistic input which would turn to an integer and output the time from the start of the route to that station, including stops at each station. This way, you can simply do "Finish Station" - "Start Station" to get the base time that it will take between any 2 stations.
Station linguistic variables:
A = 1
B = 2
C = 3
This way you can use the station name as an index into an array or in a switch statement.
The Time of day input would have a domain of 0-23 (hours) and would have 2 peaks in its graph to represent peak times (7am-9am & 3pm-6pm for example)
Once you have calculated the base time it would take, then you simply need to add on the weighted times from each of the inputs
Time = "Finish Station" - "Start Station" + "Time of day" * 2min + "How wet it is" * 5min
This explanation is not strictly a Fuzzy Inference System, but it will be much easier for you to code and understand.