Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 5)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/PredictionByPartialMatch.java	(revision 6)
@@ -63,75 +63,4 @@
 			trie.add(sequence.subList(sequenceLength-j, sequenceLength));
 		}
-	}
-	
-	public void testStuff() {
-		// basically an inline unit test without assertions but manual observation
-		List<String> list = new ArrayList<String>();
-		list.add(initialSymbol);
-		list.add("a");
-		list.add("b");
-		list.add("r");
-		list.add("a");
-		list.add("c");
-		list.add("a");
-		list.add("d");
-		list.add("a");
-		list.add("b");
-		list.add("r");
-		list.add("a");
-		list.add(endSymbol);
-		
-		PredictionByPartialMatch model = new PredictionByPartialMatch();
-		model.trie = new Trie<String>();
-		model.trainStringTrie(list);
-		model.trie.display();
-		Console.println("------------------------");
-		model.randomSequence();/*
-		Console.println("------------------------");
-		model.randomSequence();
-		Console.println("------------------------");
-		model.randomSequence();
-		Console.println("------------------------");*/
-		
-		List<String> context = new ArrayList<String>();
-		String symbol = "a";
-		// expected: 5
-		Console.traceln(""+model.trie.getCount(context, symbol));
-		
-		// expected: 0
-		context.add("b");
-		Console.traceln(""+model.trie.getCount(context, symbol));
-		
-		// expected: 2
-		context.add("r");
-		Console.traceln(""+model.trie.getCount(context, symbol));
-		
-		// exptected: [b, r]
-		context = new ArrayList<String>();
-		context.add("a");
-		context.add("b");
-		context.add("r");
-		Console.traceln(model.trie.getContextSuffix(context).toString());
-		
-		// exptected: []
-		context = new ArrayList<String>();
-		context.add("e");
-		Console.traceln(model.trie.getContextSuffix(context).toString());
-		
-		// exptected: {a, b, c, d, r}
-		context = new ArrayList<String>();
-		Console.traceln(model.trie.getFollowingSymbols(context).toString());
-		
-		// exptected: {b, c, d}
-		context = new ArrayList<String>();
-		context.add("a");
-		Console.traceln(model.trie.getFollowingSymbols(context).toString());
-		
-		// exptected: []
-		context = new ArrayList<String>();
-		context.add("a");
-		context.add("b");
-		context.add("r");
-		Console.traceln(model.trie.getFollowingSymbols(context).toString());
 	}
 	
@@ -163,42 +92,6 @@
 		return sequence;
 	}
-	
-	/*public void printRandomWalk(Random r) {
-		IncompleteMemory<String> context = new IncompleteMemory<String>(maxOrder-1);
-		
-		context.add(initialSymbol);
-		
-		String currentState = initialSymbol;
-		
-		Console.println(currentState);
-		while(!endSymbol.equals(currentState)) {
-			double randVal = r.nextDouble();
-			double probSum = 0.0;
-			List<String> currentContext = context.getLast(maxOrder);
-			// DEBUG //
-			Console.traceln("Context: " + currentContext.toString());
-			double tmpSum = 0.0d;
-			for( String symbol : knownSymbols ) {
-				double prob = getProbability(currentContext, symbol);
-				tmpSum += prob;
-				Console.traceln(symbol + ": " + prob);
-			}
-			Console.traceln("Sum: " + tmpSum);
-			// DEBUG-END //
-			for( String symbol : knownSymbols ) {
-				probSum += getProbability(currentContext, symbol);
-				if( probSum>=randVal-0.3 ) {
-					context.add(symbol);
-					currentState = symbol;
-					Console.println(currentState);
-					break;
-				}
-			}
-		}
-	}*/
-	
+		
 	private double getProbability(List<String> context, String symbol) {
-		// FIXME needs exception handling for unknown symbols
-		// if the symbol is not contained in the trie, context.remove(0) will fail
 		double result = 0.0d;
 		double resultCurrentContex = 0.0d;
@@ -232,39 +125,83 @@
 	}
 	
-	/*
-	private double getProbability(List<String> context, String symbol) {
-		double result = 0.0; 
-		int countContextSymbol = 0;
-		List<String> contextSuffix = trie.getContextSuffix(context);
-		if( contextSuffix.isEmpty() ) {
-			// unobserved context! everything is possible... assuming identical distribution
-			result = 1.0d / knownSymbols.size(); // why 1.0 and not N(symbol)
-		} else {
-			countContextSymbol = trie.getCount(contextSuffix, symbol);
-			List<String> followers = trie.getFollowingSymbols(contextSuffix);
-			int countContextFollowers = 0;
-			for( String follower : followers ) {
-				countContextFollowers += trie.getCount(contextSuffix, follower);
-			}
-			
-			if( followers.isEmpty() ) {
-				throw new AssertionError("Invalid return value of trie.getContextSuffix()!");
-			}
-			if( countContextSymbol!=0 ) {
-				result = ((double) countContextSymbol) / (followers.size()+countContextFollowers);
-			} else { // escape
-				double probEscape = ((double) followers.size()) / (followers.size()+countContextFollowers);
-				contextSuffix.remove(0); 
-				double probSuffix = getProbability(contextSuffix, symbol);
-				result = probEscape*probSuffix;
-			}
-		}
-
-		return result;
-	}*/
-	
 	@Override
 	public String toString() {
 		return trie.toString();
 	}
+	
+	public void testStuff() {
+		// basically an inline unit test without assertions but manual observation
+		List<String> list = new ArrayList<String>();
+		list.add(initialSymbol);
+		list.add("a");
+		list.add("b");
+		list.add("r");
+		list.add("a");
+		list.add("c");
+		list.add("a");
+		list.add("d");
+		list.add("a");
+		list.add("b");
+		list.add("r");
+		list.add("a");
+		list.add(endSymbol);
+		
+		PredictionByPartialMatch model = new PredictionByPartialMatch();
+		model.trie = new Trie<String>();
+		model.trainStringTrie(list);
+		model.trie.display();
+		Console.println("------------------------");
+		model.randomSequence();/*
+		Console.println("------------------------");
+		model.randomSequence();
+		Console.println("------------------------");
+		model.randomSequence();
+		Console.println("------------------------");*/
+		
+		List<String> context = new ArrayList<String>();
+		String symbol = "a";
+		// expected: 5
+		Console.traceln(""+model.trie.getCount(context, symbol));
+		
+		// expected: 0
+		context.add("b");
+		Console.traceln(""+model.trie.getCount(context, symbol));
+		
+		// expected: 2
+		context.add("r");
+		Console.traceln(""+model.trie.getCount(context, symbol));
+		
+		// exptected: [b, r]
+		context = new ArrayList<String>();
+		context.add("a");
+		context.add("b");
+		context.add("r");
+		Console.traceln(model.trie.getContextSuffix(context).toString());
+		
+		// exptected: []
+		context = new ArrayList<String>();
+		context.add("e");
+		Console.traceln(model.trie.getContextSuffix(context).toString());
+		
+		// exptected: {a, b, c, d, r}
+		context = new ArrayList<String>();
+		Console.traceln(model.trie.getFollowingSymbols(context).toString());
+		
+		// exptected: {b, c, d}
+		context = new ArrayList<String>();
+		context.add("a");
+		Console.traceln(model.trie.getFollowingSymbols(context).toString());
+		
+		// exptected: []
+		context = new ArrayList<String>();
+		context.add("a");
+		context.add("b");
+		context.add("r");
+		Console.traceln(model.trie.getFollowingSymbols(context).toString());
+		
+		// exptected: 0.0d
+		context = new ArrayList<String>();
+		context.add("a");
+		Console.traceln(""+model.getProbability(context, "z"));
+	}
 }
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java	(revision 5)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/Trie.java	(revision 6)
@@ -21,7 +21,9 @@
 public class Trie<T> {
 	
-	// Children of the Trie root
-	// should contain counts of all elements
-	private List<TrieNode<T>> children = new LinkedList<TrieNode<T>>();
+	private final TrieNode<T> rootNode;
+	
+	public Trie() {
+		rootNode = new TrieNode<T>();
+	}
 	
 
@@ -30,26 +32,15 @@
 			subsequence = new LinkedList<T>(subsequence);  // defensive copy!
 			T firstSymbol = subsequence.get(0);
-			getChildCreate(firstSymbol).add(subsequence);
+			TrieNode<T> node = getChildCreate(firstSymbol);
+			node.add(subsequence);
 		}
 	}
 
-	// FIXME clones of TrieNode.getChildCreate
 	protected TrieNode<T>  getChildCreate(T symbol) {
-		TrieNode<T> node = getChild(symbol);
-		if( node==null ) {
-			node = new TrieNode<T>(symbol);
-			children.add(node);
-		}
-		return node;
+		return rootNode.getChildCreate(symbol);
 	}
 	
-	// FIXME clones of TrieNode.getChild
 	protected TrieNode<T> getChild(T symbol) {
-		for( TrieNode<T> child : children ) {
-			if( child.getSymbol().equals(symbol) ) {
-				return child;
-			}
-		}
-		return null;
+		return rootNode.getChild(symbol);
 	}
 
@@ -73,12 +64,13 @@
 	
 	public TrieNode<T> find(List<T> sequence) {
+		if( sequence==null || sequence.isEmpty() ) {
+			return rootNode;
+		}
 		List<T> sequenceCopy = new LinkedList<T>(sequence);
 		TrieNode<T> result = null;
-		if( !sequenceCopy.isEmpty() ) {
-			TrieNode<T> node = getChild(sequenceCopy.get(0));
-			if( node!=null ) {
-				sequenceCopy.remove(0);
-				result = node.find(sequenceCopy);
-			}
+		TrieNode<T> node = getChild(sequenceCopy.get(0));
+		if( node!=null ) {
+			sequenceCopy.remove(0);
+			result = node.find(sequenceCopy);
 		}
 		return result;
@@ -88,13 +80,7 @@
 	public List<T> getFollowingSymbols(List<T> sequence) {
 		List<T> result = new LinkedList<T>();
-		if( sequence==null || sequence.isEmpty() ) {
-			for( TrieNode<T> child : children ) {
-				result.add(child.getSymbol());
-			}
-		} else {
-			TrieNode<T> node = find(sequence);
-			if( node!=null ) {
-				result = node.getFollowingSymbols();
-			}
+		TrieNode<T> node = find(sequence);
+		if( node!=null ) {
+			result = node.getFollowingSymbols();
 		}
 		return result;
@@ -102,4 +88,5 @@
 	
 	// longest suffix of context, that is contained in the tree and whose children are leaves
+	// possibly already deprecated
 	public List<T> getContextSuffix(List<T> context) {
 		List<T> contextSuffix = new LinkedList<T>(context); // defensive copy
@@ -140,12 +127,5 @@
 	private Tree<TrieVertex, Edge> getGraph() {
 		DelegateTree<TrieVertex, Edge> graph = new DelegateTree<TrieVertex, Edge>();
-		
-		TrieVertex root = new TrieVertex("root");
-		graph.addVertex(root);
-				
-		for( TrieNode<T> node : children ) {
-			node.getGraph(root, graph);
-		}
-		
+		rootNode.getGraph(null, graph);
 		return graph;
 	}
@@ -181,5 +161,5 @@
 	@Override
 	public String toString() {
-		return children.toString();
+		return rootNode.toString();
 	}
 }
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java	(revision 5)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/ppm/TrieNode.java	(revision 6)
@@ -17,4 +17,10 @@
 	
 	private List<TrieNode<T>> children;
+	
+	TrieNode() {
+		this.symbol = null;
+		count = 0;
+		children = new LinkedList<TrieNode<T>>();
+	}
 	
 	public TrieNode(T symbol) {
@@ -102,8 +108,14 @@
 
 	public void getGraph(TrieVertex parent, DelegateTree<TrieVertex, Edge> graph) {
-		TrieVertex vertex = new TrieVertex(getSymbol().toString()+"#"+getCount());
-		graph.addChild( new Edge() , parent, vertex );
+		TrieVertex currentVertex;
+		if( symbol==null ){
+			currentVertex = new TrieVertex("root");
+			graph.addVertex(currentVertex);
+		} else {
+			currentVertex = new TrieVertex(getSymbol().toString()+"#"+getCount());
+			graph.addChild( new Edge() , parent, currentVertex );
+		}
 		for( TrieNode<T> node : children ) {
-			node.getGraph(vertex, graph);
+			node.getGraph(currentVertex, graph);
 		}		
 	}
