Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Predict next event occurrence, based on past occurrences

I'm looking for an algorithm or example material to study for predicting future events based on known patterns. Perhaps there is a name for this, and I just don't know/remember it. Something this general may not exist, but I'm not a master of math or algorithms, so I'm here asking for direction.

An example, as I understand it would be something like this:

A static event occurs on January 1st, February 1st, March 3rd, April 4th. A simple solution would be to average the days/hours/minutes/something between each occurrence, add that number to the last known occurrence, and have the prediction.

What am I asking for, or what should I study?

There is no particular goal in mind, or any specific variables to account for. This is simply a personal thought, and an opportunity for me to learn something new.

like image 603
anonymous coward Avatar asked Apr 16 '09 21:04

anonymous coward


2 Answers

I think some topics that might be worth looking into include numerical analysis, specifically interpolation, extrapolation, and regression.

like image 173
Lance Harper Avatar answered Nov 16 '22 01:11

Lance Harper


This could be overkill, but Markov chains can lead to some pretty cool pattern recognition stuff. It's better suited to, well, chains of events: the idea is, based on the last N steps in a chain of events, what will happen next?

This is well suited to text: process a large sample of Shakespeare, and you can generate paragraphs full of Shakespeare-like nonsense! Unfortunately, it takes a good deal more data to figure out sparsely-populated events. (Detecting patterns with a period of a month or more would require you to track a chain of at least a full month of data.)

In pseudo-python, here's a rough sketch of a Markov chain builder/prediction script:

n = how_big_a_chain_you_want
def build_map(eventChain):
    map = defaultdict(list)
    for events in get_all_n_plus_1_item_slices_of(eventChain):
        slice = events[:n]
        last = events[-1]
        map[slice].append(last)

def predict_next_event(whatsHappenedSoFar, map):
    slice = whatsHappenedSoFar[-n:]
    return random_choice(map[slice])
like image 29
ojrac Avatar answered Nov 16 '22 01:11

ojrac