Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/DeterministicFiniteAutomaton.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/DeterministicFiniteAutomaton.java	(revision 100)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/DeterministicFiniteAutomaton.java	(revision 101)
@@ -7,33 +7,64 @@
 import de.ugoe.cs.eventbench.data.Event;
 
+/**
+ * <p>
+ * Implements a Deterministic Finite Automata (DFA) capable of random session
+ * generation. It is a special case of a first-order Markov model, where the
+ * transition probability is equally high for all following states.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
 public class DeterministicFiniteAutomaton extends FirstOrderMarkovModel {
 
 	/**
+	 * <p>
 	 * Id for object serialization.
+	 * </p>
 	 */
 	private static final long serialVersionUID = 1L;
 
+	/**
+	 * <p>
+	 * Constructor. Creates a new DeterministicFiniteAutomaton.
+	 * </p>
+	 * 
+	 * @param r
+	 *            random number generator used by probabilistic methods of the
+	 *            class
+	 */
 	public DeterministicFiniteAutomaton(Random r) {
 		super(r);
 	}
 
+	/**
+	 * <p>
+	 * Calculates the proability of the next state. Each of the following states
+	 * in the automaton is equally probable.
+	 * </p>
+	 * 
+	 * @see de.ugoe.cs.eventbench.models.IStochasticProcess#getProbability(java.util.List,
+	 *      de.ugoe.cs.eventbench.data.Event)
+	 */
 	@Override
-	public double getProbability(List<? extends Event<?>> context, Event<?> symbol) {
+	public double getProbability(List<? extends Event<?>> context,
+			Event<?> symbol) {
 		double result = 0.0d;
-		
+
 		List<Event<?>> contextCopy;
-		if( context.size()>=trieOrder ) {
-			contextCopy = new LinkedList<Event<?>>(context.subList(context.size()-trieOrder+1, context.size()));
+		if (context.size() >= trieOrder) {
+			contextCopy = new LinkedList<Event<?>>(context.subList(
+					context.size() - trieOrder + 1, context.size()));
 		} else {
 			contextCopy = new LinkedList<Event<?>>(context);
 		}
 
-	
 		List<Event<?>> followers = trie.getFollowingSymbols(contextCopy);
-		
-		if( followers.size()!=0 && followers.contains(symbol) ) {
+
+		if (followers.size() != 0 && followers.contains(symbol)) {
 			result = 1.0d / followers.size();
 		}
-		
+
 		return result;
 	}
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModel.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModel.java	(revision 100)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModel.java	(revision 101)
@@ -14,27 +14,65 @@
 import Jama.Matrix;
 
-public class FirstOrderMarkovModel extends HighOrderMarkovModel implements IDotCompatible {
-
-	/**
+/**
+ * <p>
+ * Implements first-order Markov models. The implementation is based on
+ * {@link HighOrderMarkovModel} and restricts the Markov order to 1. In
+ * comparison to {@link HighOrderMarkovModel}, more calculations are possible
+ * with first-order models, e.g., the calculation of the entropy (
+ * {@link #calcEntropy()}).
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
+public class FirstOrderMarkovModel extends HighOrderMarkovModel implements
+		IDotCompatible {
+
+	/**
+	 * <p>
 	 * Id for object serialization.
+	 * </p>
 	 */
 	private static final long serialVersionUID = 1L;
-	
+
+	/**
+	 * <p>
+	 * Maximum number of iterations when calculating the stationary distribution
+	 * as the limit of multiplying the transmission matrix with itself.
+	 * </p>
+	 */
 	final static int MAX_STATDIST_ITERATIONS = 1000;
-	
+
+	/**
+	 * <p>
+	 * Constructor. Creates a new FirstOrderMarkovModel.
+	 * </p>
+	 * 
+	 * @param r
+	 *            random number generator used by probabilistic methods of the
+	 *            class
+	 */
 	public FirstOrderMarkovModel(Random r) {
 		super(1, r);
 	}
-	
+
+	/**
+	 * <p>
+	 * Generates the transmission matrix of the Markov model.
+	 * </p>
+	 * 
+	 * @return transmission matrix
+	 */
 	private Matrix getTransmissionMatrix() {
-		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(trie.getKnownSymbols());
+		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(
+				trie.getKnownSymbols());
 		int numStates = knownSymbols.size();
 		Matrix transmissionMatrix = new Matrix(numStates, numStates);
-		
-		for( int i=0 ; i<numStates ; i++ ) {
+
+		for (int i = 0; i < numStates; i++) {
 			Event<?> currentSymbol = knownSymbols.get(i);
 			List<Event<?>> context = new ArrayList<Event<?>>();
 			context.add(currentSymbol);
-			for( int j=0 ; j<numStates ; j++ ) {
+			for (int j = 0; j < numStates; j++) {
 				Event<?> follower = knownSymbols.get(j);
 				double prob = getProbability(context, follower);
@@ -44,20 +82,96 @@
 		return transmissionMatrix;
 	}
-	
+
+	/**
+	 * <p>
+	 * Calculates the entropy of the model. To make it possible that the model
+	 * is stationary, a transition from {@link Event#ENDEVENT} to
+	 * {@link Event#STARTEVENT} is added.
+	 * </p>
+	 * 
+	 * @return entropy of the model or NaN if it could not be calculated
+	 */
+	public double calcEntropy() {
+		Matrix transmissionMatrix = getTransmissionMatrix();
+		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(
+				trie.getKnownSymbols());
+		int numStates = knownSymbols.size();
+
+		int startStateIndex = knownSymbols.indexOf(Event.STARTEVENT);
+		int endStateIndex = knownSymbols.indexOf(Event.ENDEVENT);
+		if (startStateIndex == -1) {
+			Console.printerrln("Error calculating entropy. Initial state of markov chain not found.");
+			return Double.NaN;
+		}
+		if (endStateIndex == -1) {
+			Console.printerrln("Error calculating entropy. End state of markov chain not found.");
+			return Double.NaN;
+		}
+		transmissionMatrix.set(endStateIndex, startStateIndex, 1);
+
+		// Calculate stationary distribution by raising the power of the
+		// transmission matrix.
+		// The rank of the matrix should fall to 1 and each two should be the
+		// vector of the stationory distribution.
+		int iter = 0;
+		int rank = transmissionMatrix.rank();
+		Matrix stationaryMatrix = (Matrix) transmissionMatrix.clone();
+		while (iter < MAX_STATDIST_ITERATIONS && rank > 1) {
+			stationaryMatrix = stationaryMatrix.times(stationaryMatrix);
+			rank = stationaryMatrix.rank();
+			iter++;
+		}
+
+		if (rank != 1) {
+			Console.traceln("rank: " + rank);
+			Console.printerrln("Unable to calculate stationary distribution.");
+			return Double.NaN;
+		}
+
+		double entropy = 0.0;
+		for (int i = 0; i < numStates; i++) {
+			for (int j = 0; j < numStates; j++) {
+				if (transmissionMatrix.get(i, j) != 0) {
+					double tmp = stationaryMatrix.get(i, 0);
+					tmp *= transmissionMatrix.get(i, j);
+					tmp *= Math.log(transmissionMatrix.get(i, j)) / Math.log(2);
+					entropy -= tmp;
+				}
+			}
+		}
+		return entropy;
+	}
+
+	/**
+	 * <p>
+	 * The dot represenation of {@link FirstOrderMarkovModel}s is its graph
+	 * representation with the states as nodes and directed edges weighted with
+	 * transition probabilities.
+	 * </p>
+	 * 
+	 * @see de.ugoe.cs.eventbench.models.IDotCompatible#getDotRepresentation()
+	 */
+	@Override
 	public String getDotRepresentation() {
 		StringBuilder stringBuilder = new StringBuilder();
 		stringBuilder.append("digraph model {" + StringTools.ENDLINE);
 
-		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(trie.getKnownSymbols());
-		
-		for( Event<?> symbol : knownSymbols) {
-			final String thisSaneId = symbol.getShortId().replace("\"", "\\\"").replaceAll("[\r\n]","");
-			stringBuilder.append(" " + symbol.hashCode() + " [label=\""+thisSaneId+"\"];" + StringTools.ENDLINE);
+		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(
+				trie.getKnownSymbols());
+
+		for (Event<?> symbol : knownSymbols) {
+			final String thisSaneId = symbol.getShortId().replace("\"", "\\\"")
+					.replaceAll("[\r\n]", "");
+			stringBuilder.append(" " + symbol.hashCode() + " [label=\""
+					+ thisSaneId + "\"];" + StringTools.ENDLINE);
 			List<Event<?>> context = new ArrayList<Event<?>>();
-			context.add(symbol); 
+			context.add(symbol);
 			List<Event<?>> followers = trie.getFollowingSymbols(context);
-			for( Event<?> follower : followers ) {
-				stringBuilder.append(" "+symbol.hashCode()+" -> " + follower.hashCode() + " ");
-				stringBuilder.append("[label=\"" + getProbability(context, follower) + "\"];" + StringTools.ENDLINE);
+			for (Event<?> follower : followers) {
+				stringBuilder.append(" " + symbol.hashCode() + " -> "
+						+ follower.hashCode() + " ");
+				stringBuilder.append("[label=\""
+						+ getProbability(context, follower) + "\"];"
+						+ StringTools.ENDLINE);
 			}
 		}
@@ -65,20 +179,30 @@
 		return stringBuilder.toString();
 	}
-	
+
+	/**
+	 * <p>
+	 * Returns a {@link Graph} represenation of the model with the states as
+	 * nodes and directed edges weighted with transition probabilities.
+	 * </p>
+	 * 
+	 * @return {@link Graph} of the model
+	 */
 	public Graph<String, MarkovEdge> getGraph() {
 		Graph<String, MarkovEdge> graph = new SparseMultigraph<String, MarkovEdge>();
-		
-		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(trie.getKnownSymbols());
-		
-		for( Event<?> symbol : knownSymbols) {
+
+		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(
+				trie.getKnownSymbols());
+
+		for (Event<?> symbol : knownSymbols) {
 			String from = symbol.getShortId();
 			List<Event<?>> context = new ArrayList<Event<?>>();
-			context.add(symbol); 
-			
+			context.add(symbol);
+
 			List<Event<?>> followers = trie.getFollowingSymbols(context);
-			
-			for( Event<?> follower : followers ) {
+
+			for (Event<?> follower : followers) {
 				String to = follower.getShortId();
-				MarkovEdge prob = new MarkovEdge(getProbability(context, follower));
+				MarkovEdge prob = new MarkovEdge(getProbability(context,
+						follower));
 				graph.addEdge(prob, from, to, EdgeType.DIRECTED);
 			}
@@ -86,58 +210,39 @@
 		return graph;
 	}
-	
+
+	/**
+	 * Inner class used for the {@link Graph} representation of the model.
+	 * 
+	 * @author Steffen Herbold
+	 * @version 1.0
+	 */
 	static public class MarkovEdge {
+		/**
+		 * <p>
+		 * Weight of the edge, i.e., its transition probability.
+		 * </p>
+		 */
 		double weight;
-		MarkovEdge(double weight) { this.weight = weight; }
-		public String toString() { return ""+weight; }
-	}
-	
-	public double calcEntropy() {
-		Matrix transmissionMatrix = getTransmissionMatrix();
-		List<Event<?>> knownSymbols = new ArrayList<Event<?>>(trie.getKnownSymbols());
-		int numStates = knownSymbols.size();
-		
-		int startStateIndex = knownSymbols.indexOf(Event.STARTEVENT);
-		int endStateIndex = knownSymbols.indexOf(Event.ENDEVENT);
-		if( startStateIndex==-1 ) {
-			Console.printerrln("Error calculating entropy. Initial state of markov chain not found.");
-			return Double.NaN;
-		}
-		if( endStateIndex==-1 ) {
-			Console.printerrln("Error calculating entropy. End state of markov chain not found.");
-			return Double.NaN;
-		}
-		transmissionMatrix.set(endStateIndex, startStateIndex, 1);
-		
-		// Calculate stationary distribution by raising the power of the transmission matrix.
-		// The rank of the matrix should fall to 1 and each two should be the vector of the
-		// stationory distribution. 
-		int iter = 0;
-		int rank = transmissionMatrix.rank();
-		Matrix stationaryMatrix = (Matrix) transmissionMatrix.clone();
-		while( iter<MAX_STATDIST_ITERATIONS && rank>1 ) {
-			stationaryMatrix = stationaryMatrix.times(stationaryMatrix);
-			rank = stationaryMatrix.rank();
-			iter++;
-		}
-		
-		if( rank!=1 ) {
-			Console.traceln("rank: " + rank);
-			Console.printerrln("Unable to calculate stationary distribution.");
-			return Double.NaN;
-		}
-		
-		double entropy = 0.0;
-		for( int i=0 ; i<numStates ; i++ ) {
-			for( int j=0 ; j<numStates ; j++ ) {
-				if( transmissionMatrix.get(i,j)!=0 ) {
-					double tmp = stationaryMatrix.get(i, 0);
-					tmp *= transmissionMatrix.get(i, j);
-					tmp *= Math.log(transmissionMatrix.get(i,j))/Math.log(2);
-					entropy -= tmp;
-				}
-			}
-		}
-		return entropy;
+
+		/**
+		 * <p>
+		 * Constructor. Creates a new MarkovEdge.
+		 * </p>
+		 * 
+		 * @param weight
+		 *            weight of the edge, i.e., its transition probability
+		 */
+		MarkovEdge(double weight) {
+			this.weight = weight;
+		}
+
+		/**
+		 * <p>
+		 * The weight of the edge as {@link String}.
+		 * </p>
+		 */
+		public String toString() {
+			return "" + weight;
+		}
 	}
 
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/HighOrderMarkovModel.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/HighOrderMarkovModel.java	(revision 100)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/HighOrderMarkovModel.java	(revision 101)
@@ -7,15 +7,34 @@
 import de.ugoe.cs.eventbench.data.Event;
 
+/**
+ * <p>Implements high-order Markov models.</p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
 public class HighOrderMarkovModel extends TrieBasedModel {
 	
 	/**
+	 * <p>
 	 * Id for object serialization.
+	 * </p>
 	 */
 	private static final long serialVersionUID = 1L;
 
+	/**
+	 * <p>Constructor. Creates a new HighOrderMarkovModel with a defined Markov order.</p>
+	 * @param maxOrder Markov order of the model
+	 * @param r random number generator used by probabilistic methods of the class
+	 */
 	public HighOrderMarkovModel(int maxOrder, Random r) {
 		super(maxOrder, r);
 	}
 	
+	/**
+	 * <p>
+	 * Calculates the probability of the next Event being symbol based on the order of the Markov model. The order is defined in the constructor {@link #HighOrderMarkovModel(int, Random)}. 
+	 * </p>
+	 * @see de.ugoe.cs.eventbench.models.IStochasticProcess#getProbability(java.util.List, de.ugoe.cs.eventbench.data.Event)
+	 */
 	@Override
 	public double getProbability(List<? extends Event<?>> context, Event<?> symbol) {
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IDotCompatible.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IDotCompatible.java	(revision 100)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IDotCompatible.java	(revision 101)
@@ -1,5 +1,22 @@
 package de.ugoe.cs.eventbench.models;
 
+/**
+ * <p>
+ * Models implementing this interface provide a graph representation of
+ * themselves as a {@link String} with Dot syntax.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
 public interface IDotCompatible {
+
+	/**
+	 * <p>
+	 * Returns a Dot representation of the model.
+	 * </p>
+	 * 
+	 * @return string with Dot syntax that describes the model.
+	 */
 	public abstract String getDotRepresentation();
 }
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java	(revision 100)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java	(revision 101)
@@ -7,70 +7,139 @@
 import de.ugoe.cs.eventbench.data.Event;
 
+/**
+ * <p>
+ * Implements Prediction by Partial Match (PPM) based on the following formula
+ * (LaTeX-style notation):<br>
+ * 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)<br>
+ * P_{MM^i} denotes the probability in an i-th order Markov model.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * 
+ */
 public class PredictionByPartialMatch extends TrieBasedModel {
-	
+
 	/**
+	 * <p>
 	 * Id for object serialization.
+	 * </p>
 	 */
 	private static final long serialVersionUID = 1L;
-	
+
+	/**
+	 * <p>
+	 * Probability to use a lower-order Markov model
+	 * </p>
+	 */
 	double probEscape;
-	
+
+	/**
+	 * <p>
+	 * Constructor. Creates a new PredictionByPartialMatch model with a given
+	 * Markov order and a default escape probability of 0.1.
+	 * </p>
+	 * 
+	 * @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);
 	}
-	
+
+	/**
+	 * <p>
+	 * Creates a new PredictionByPartialMatch model with a given Markov order
+	 * and escape probability.
+	 * </p>
+	 * 
+	 * @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;
 	}
-	
+
+	/**
+	 * <p>
+	 * Sets the escape probability of the model.
+	 * </p>
+	 * 
+	 * @param probEscape
+	 *            new escape probability
+	 */
 	public void setProbEscape(double probEscape) {
 		this.probEscape = probEscape;
 	}
-	
+
+	/**
+	 * <p>
+	 * Returns the escape probability of the model.
+	 * </p>
+	 * 
+	 * @return escape probability of the model
+	 */
 	public double getProbEscape() {
 		return probEscape;
 	}
-	
+
+	/**
+	 * <p>
+	 * Calculates the probability of the next event based on the formula:<br>
+	 * 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)<br>
+	 * P_{MM^i} denotes the probability in an i-th order Markov model.
+	 * </p>
+	 */
 	@Override
-	public double getProbability(List<? extends Event<?>> context, Event<?> symbol) {
+	public double getProbability(List<? extends Event<?>> context,
+			Event<?> symbol) {
 		double result = 0.0d;
 		double resultCurrentContex = 0.0d;
 		double resultShorterContex = 0.0d;
-		
+
 		List<Event<?>> contextCopy;
-		if( context.size()>=trieOrder ) {
-			contextCopy = new LinkedList<Event<?>>(context.subList(context.size()-trieOrder+1, context.size()));
+		if (context.size() >= trieOrder) {
+			contextCopy = new LinkedList<Event<?>>(context.subList(
+					context.size() - trieOrder + 1, context.size()));
 		} else {
 			contextCopy = new LinkedList<Event<?>>(context);
 		}
 
-	
 		List<Event<?>> followers = trie.getFollowingSymbols(contextCopy); // \Sigma'
 		int sumCountFollowers = 0; // N(s\sigma')
-		for( Event<?> follower : followers ) {
+		for (Event<?> follower : followers) {
 			sumCountFollowers += trie.getCount(contextCopy, follower);
 		}
-		
+
 		int countSymbol = trie.getCount(contextCopy, symbol); // N(s\sigma)
-		if( contextCopy.size()==0 ) {
+		if (contextCopy.size() == 0) {
 			resultCurrentContex = ((double) countSymbol) / sumCountFollowers;
 		} else {
-			if( sumCountFollowers==0 ) {
+			if (sumCountFollowers == 0) {
 				resultCurrentContex = 0.0;
+			} else {
+				resultCurrentContex = ((double) countSymbol / sumCountFollowers)
+						* (1 - probEscape);
 			}
-			else {
-				resultCurrentContex = ((double) countSymbol / sumCountFollowers)*(1-probEscape);
-			}
-			contextCopy.remove(0); 
+			contextCopy.remove(0);
 			double probSuffix = getProbability(contextCopy, symbol);
-			if( followers.size()==0 ) {
+			if (followers.size() == 0) {
 				resultShorterContex = probSuffix;
 			} else {
-				resultShorterContex = probEscape*probSuffix;
+				resultShorterContex = probEscape * probSuffix;
 			}
 		}
-		result = resultCurrentContex+resultShorterContex;
-		
+		result = resultCurrentContex + resultShorterContex;
+
 		return result;
 	}
