package de.ugoe.cs.eventbench.models; import java.util.LinkedList; import java.util.List; import java.util.Random; import de.ugoe.cs.eventbench.data.Event; /** *
* Implements Prediction by Partial Match (PPM) based on the following formula
* (LaTeX-style notation):
* P_{PPM}(X_n|X_{n-1},...,X_{n-k}) = \sum_{i=k}^1 escape^{i-1}
* P_{MM^i}(X_n|X_{n-1},...,X_{n-i})(1-escape)
* P_{MM^i} denotes the probability in an i-th order Markov model.
*
* Id for object serialization. *
*/ private static final long serialVersionUID = 1L; /** ** Probability to use a lower-order Markov model *
*/ double probEscape; /** ** Constructor. Creates a new PredictionByPartialMatch model with a given * Markov order and a default escape probability of 0.1. *
* * @param markovOrder * Markov order of the model * @param r * random number generator used by probabilistic methods of the * class */ public PredictionByPartialMatch(int markovOrder, Random r) { this(markovOrder, r, 0.1); } /** ** Creates a new PredictionByPartialMatch model with a given Markov order * and escape probability. *
* * @param markovOrder * Markov order of the model * @param r * random number generator used by probabilistic methods of the * class * @param probEscape * escape probability used by the model */ public PredictionByPartialMatch(int markovOrder, Random r, double probEscape) { super(markovOrder, r); this.probEscape = probEscape; } /** ** Sets the escape probability of the model. *
* * @param probEscape * new escape probability */ public void setProbEscape(double probEscape) { this.probEscape = probEscape; } /** ** Returns the escape probability of the model. *
* * @return escape probability of the model */ public double getProbEscape() { return probEscape; } /** *
* Calculates the probability of the next event based on the formula:
* P_{PPM}(X_n|X_{n-1},...,X_{n-k}) = \sum_{i=k}^1 escape^{i-1}
* P_{MM^i}(X_n|X_{n-1},...,X_{n-i})(1-escape)
* P_{MM^i} denotes the probability in an i-th order Markov model.
*