Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculator.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculator.java	(revision 122)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculator.java	(revision 123)
@@ -3,10 +3,6 @@
 import java.security.InvalidParameterException;
 import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 import de.ugoe.cs.eventbench.data.Event;
@@ -15,5 +11,6 @@
 /**
  * <p>
- * This class calculates various types of sequence coverage.
+ * This class calculates various types of sequence coverage in relation to a
+ * stochastic process.
  * </p>
  * 
@@ -76,5 +73,6 @@
 	 * 
 	 * @param process
-	 *            stochastic process used for coverage calculations; must not be null
+	 *            stochastic process used for coverage calculations; must not be
+	 *            null
 	 * @param sequences
 	 *            sequences for which the coverage is calculated; must not be
@@ -86,12 +84,13 @@
 	public CoverageCalculator(IStochasticProcess process,
 			Collection<List<? extends Event<?>>> sequences, int length) {
-		if( process==null ) {
+		if (process == null) {
 			throw new InvalidParameterException("process must not be null");
 		}
-		if( sequences==null ) {
+		if (sequences == null) {
 			throw new InvalidParameterException("sequences must not be null");
 		}
-		if( length<=0 ) {
-			throw new InvalidParameterException("length must be >0; actual value: " + length);
+		if (length <= 0) {
+			throw new InvalidParameterException(
+					"length must be >0; actual value: " + length);
 		}
 		this.process = process;
@@ -102,5 +101,5 @@
 	/**
 	 * <p>
-	 * Calculates the percentage of subsequences of length k that exist occur,
+	 * Calculates the percentage of subsequences of length k that occur,
 	 * including those that cannot be generated by {@link #process}.
 	 * </p>
@@ -110,8 +109,9 @@
 	public double getCoverageAllNoWeight() {
 		if (containedSubSeqs == null) {
-			containedSubSeqs = containedSubSequences(sequences, length);
+			containedSubSeqs = SequenceTools.containedSubSequences(sequences,
+					length);
 		}
 		return ((double) containedSubSeqs.size())
-				/ numSequences(process, length);
+				/ SequenceTools.numSequences(process, length);
 	}
 
@@ -126,5 +126,6 @@
 	public double getCoveragePossibleNoWeight() {
 		if (containedSubSeqs == null) {
-			containedSubSeqs = containedSubSequences(sequences, length);
+			containedSubSeqs = SequenceTools.containedSubSequences(sequences,
+					length);
 		}
 		if (allPossibleSubSeqs == null) {
@@ -145,5 +146,6 @@
 	public double getCoveragePossibleWeight() {
 		if (containedSubSeqs == null) {
-			containedSubSeqs = containedSubSequences(sequences, length);
+			containedSubSeqs = SequenceTools.containedSubSequences(sequences,
+					length);
 		}
 		if (allPossibleSubSeqs == null) {
@@ -151,5 +153,6 @@
 		}
 		if (subSeqWeights == null) {
-			subSeqWeights = generateWeights(process, allPossibleSubSeqs);
+			subSeqWeights = SequenceTools.generateWeights(process,
+					allPossibleSubSeqs);
 		}
 		double weight = 0.0;
@@ -160,88 +163,3 @@
 	}
 
-	/**
-	 * <p>
-	 * Calculates the weights for all sequences passed to this function as
-	 * defined by the stochastic process and stores them in a {@link Map}.
-	 * </p>
-	 * 
-	 * @param process
-	 *            process used for weight calculation
-	 * @param sequences
-	 *            sequences for which the weights are calculated
-	 * @return {@link Map} of weights
-	 */
-	private static Map<List<? extends Event<?>>, Double> generateWeights(
-			IStochasticProcess process,
-			Collection<List<? extends Event<?>>> sequences) {
-		Map<List<? extends Event<?>>, Double> subSeqWeights = new LinkedHashMap<List<? extends Event<?>>, Double>();
-		double sum = 0.0;
-		for (List<? extends Event<?>> sequence : sequences) {
-			double prob = process.getProbability(sequence);
-			subSeqWeights.put(sequence, prob);
-			sum += prob;
-		}
-		if (sum < 1.0) {
-			for (Map.Entry<List<? extends Event<?>>, Double> entry : subSeqWeights
-					.entrySet()) {
-				entry.setValue(entry.getValue() / sum);
-			}
-		}
-		return subSeqWeights;
-	}
-
-	/**
-	 * <p>
-	 * Calculates the number of all existing sequences of a given length,
-	 * regardless whether they are possible or not.
-	 * </p>
-	 * 
-	 * @param process
-	 *            stochastic process whose symbols are the basis for this
-	 *            calculation
-	 * @param length
-	 *            lenght of the sequences
-	 * @return numStates^length
-	 */
-	private static long numSequences(IStochasticProcess process, int length) {
-		return (long) Math.pow(process.getNumStates(), length);
-	}
-
-	/**
-	 * <p>
-	 * Creates a {@link Set} of all subsequences of a given length that are
-	 * contained in a sequence collection.
-	 * </p>
-	 * 
-	 * @param sequences
-	 *            sequences from which the subsequences are extracted
-	 * @param length
-	 *            length of the subsequences
-	 * @return {@link Set} of all subsequences
-	 */
-	private static Set<List<? extends Event<?>>> containedSubSequences(
-			Collection<List<? extends Event<?>>> sequences, int length) {
-		Set<List<? extends Event<?>>> containedSubSeqs = new LinkedHashSet<List<? extends Event<?>>>();
-		for (List<? extends Event<?>> sequence : sequences) {
-			List<Event<?>> subSeq = new LinkedList<Event<?>>();
-			boolean minLengthReached = false;
-			for (Event<?> event : sequence) {
-				subSeq.add(event);
-				if (!minLengthReached) {
-					if (subSeq.size() == length) {
-						minLengthReached = true;
-					}
-				} else {
-					subSeq.remove(0);
-				}
-				if (minLengthReached) {
-					if (!containedSubSeqs.contains(subSeq)) {
-						containedSubSeqs.add(new LinkedList<Event<?>>(subSeq));
-					}
-				}
-			}
-		}
-		return containedSubSeqs;
-	}
-
 }
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculatorObserved.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculatorObserved.java	(revision 123)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculatorObserved.java	(revision 123)
@@ -0,0 +1,223 @@
+package de.ugoe.cs.eventbench.coverage;
+
+import java.security.InvalidParameterException;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.models.IStochasticProcess;
+
+/**
+ * <p>
+ * This class calculates various types of sequence coverage in relation to a
+ * collection of observed sequences.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
+public class CoverageCalculatorObserved {
+
+	/**
+	 * <p>
+	 * Sequences for which the coverage is calculated.
+	 * </p>
+	 */
+	private final Collection<List<? extends Event<?>>> sequences;
+
+	/**
+	 * <p>
+	 * Observed sequences that are baseline for the coverage calculation.
+	 * </p>
+	 */
+	private final Collection<List<? extends Event<?>>> observedSequences;
+
+	/**
+	 * <p>
+	 * Length of the subsequences in relation to which the covarage is
+	 * calculated.
+	 * </p>
+	 */
+	private final int length;
+
+	/**
+	 * <p>
+	 * All subsequences of {@link #length} of {@link #sequences}.
+	 * </p>
+	 */
+	private Collection<List<? extends Event<?>>> subSeqsGenerated = null;
+
+	/**
+	 * <p>
+	 * All subsequences of {@link #length} of {@link #observedSequences}.
+	 * </p>
+	 */
+	private Collection<List<? extends Event<?>>> subSeqsObserved = null;
+
+	/**
+	 * <p>
+	 * Constructor. Creates a new CoverageCalculatorObserved for given
+	 * collections of observed sequences and generated sequences.
+	 * </p>
+	 * 
+	 * @param observedSequences
+	 *            observed sequences in relation to which the coverage is
+	 *            calculated; must not be null
+	 * @param sequences
+	 *            sequences for which the coverage is calculated; must not be
+	 *            null
+	 * @param length
+	 *            length of the subsequences for which the coverage is analyzed;
+	 *            must be >0
+	 */
+	public CoverageCalculatorObserved(
+			Collection<List<? extends Event<?>>> observedSequences,
+			Collection<List<? extends Event<?>>> sequences, int length) {
+		if (observedSequences == null) {
+			throw new InvalidParameterException("process must not be null");
+		}
+		if (sequences == null) {
+			throw new InvalidParameterException("sequences must not be null");
+		}
+		if (length <= 0) {
+			throw new InvalidParameterException(
+					"length must be >0; actual value: " + length);
+		}
+		this.observedSequences = observedSequences;
+		this.sequences = sequences;
+		this.length = length;
+	}
+
+	/**
+	 * <p>
+	 * Calculates the percentage of subsequences of length k that occur, with
+	 * reference to those that were observed.
+	 * </p>
+	 * 
+	 * @return coverage percentage
+	 */
+	public double getCoverageObserved() {
+		createSubSeqs();
+		Collection<List<? extends Event<?>>> subSeqsObservedCopy = new LinkedHashSet<List<? extends Event<?>>>(
+				subSeqsObserved);
+		subSeqsObservedCopy.retainAll(subSeqsGenerated);
+		return ((double) subSeqsObservedCopy.size()) / subSeqsObserved.size();
+	}
+
+	/**
+	 * <p>
+	 * Calculates the weight of subsequences of length k that occur, with
+	 * reference to those that were observed.
+	 * </p>
+	 * 
+	 * @param process
+	 *            stochastic process in reference to which the weight is
+	 *            calculated
+	 * @return coverage percentage
+	 */
+
+	public double getCoverageObservedWeigth(IStochasticProcess process) {
+		createSubSeqs();
+		Map<List<? extends Event<?>>, Double> weightMap = SequenceTools
+				.generateWeights(process, observedSequences);
+
+		Collection<List<? extends Event<?>>> subSeqsObservedCopy = new LinkedHashSet<List<? extends Event<?>>>(
+				subSeqsObserved);
+		subSeqsObservedCopy.retainAll(subSeqsGenerated);
+		double weight = 0.0d;
+		for (List<? extends Event<?>> subSeq : subSeqsObserved) {
+			weight += weightMap.get(subSeq);
+		}
+		return weight;
+	}
+
+	/**
+	 * <p>
+	 * Calculates the percentage of generated subsequences of length k that
+	 * occur and have not been observed, with reference to all generated
+	 * subsequences.
+	 * </p>
+	 * 
+	 * @return coverage percentage
+	 */
+	public double getNewPercentage() {
+		createSubSeqs();
+		Collection<List<? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(
+				subSeqsGenerated);
+		subSeqsGeneratedCopy.removeAll(subSeqsObserved);
+		return ((double) subSeqsGeneratedCopy.size()) / subSeqsGenerated.size();
+	}
+
+	/**
+	 * <p>
+	 * Calculates the percentage of generated subsequences of length k that
+	 * occur and have not been observed, with references to all possible new
+	 * subsequences.
+	 * </p>
+	 * 
+	 * @param process
+	 *            stochastic process which is used to determine which
+	 *            subsequences are possible
+	 * @return coverage percentage
+	 */
+	public double getCoveragePossibleNew(IStochasticProcess process) {
+		createSubSeqs();
+		Collection<List<? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(
+				subSeqsGenerated);
+		Collection<List<? extends Event<?>>> subSeqsPossible = process
+				.generateSequences(length);
+		subSeqsGeneratedCopy.removeAll(subSeqsObserved);
+		subSeqsPossible.removeAll(subSeqsObserved);
+		int possibleSize = subSeqsPossible.size();
+		subSeqsPossible.retainAll(subSeqsGeneratedCopy);
+		return ((double) subSeqsPossible.size()) / possibleSize;
+	}
+
+	/**
+	 * <p>
+	 * Calculates the weight of generated subsequences of length k that occur
+	 * and have not been observed, with references to all possible new
+	 * subsequences.
+	 * </p>
+	 * 
+	 * @param process
+	 *            stochastic process which is used to determine the weights and
+	 *            which subsequences are possible
+	 * @return coverage percentage
+	 */
+	public double getCoveragePossibleNewWeight(IStochasticProcess process) {
+		createSubSeqs();
+		Collection<List<? extends Event<?>>> subSeqsGeneratedCopy = new LinkedHashSet<List<? extends Event<?>>>(
+				subSeqsGenerated);
+		Collection<List<? extends Event<?>>> subSeqsPossible = process
+				.generateSequences(length);
+		subSeqsGeneratedCopy.removeAll(subSeqsObserved);
+		subSeqsPossible.removeAll(subSeqsObserved);
+		Map<List<? extends Event<?>>, Double> weightMap = SequenceTools
+				.generateWeights(process, subSeqsPossible);
+		double weight = 0.0d;
+		for (List<? extends Event<?>> subSeq : subSeqsGeneratedCopy) {
+			weight += weightMap.get(subSeq);
+		}
+		return weight;
+	}
+
+	/**
+	 * <p>
+	 * Helper function that calcuates the subsequences of length k that have
+	 * been observed and generated.
+	 * </p>
+	 */
+	private void createSubSeqs() {
+		if (subSeqsObserved == null) {
+			subSeqsObserved = SequenceTools.containedSubSequences(
+					observedSequences, length);
+		}
+		if (subSeqsGenerated == null) {
+			subSeqsGenerated = SequenceTools.containedSubSequences(sequences,
+					length);
+		}
+	}
+}
Index: /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/SequenceTools.java
===================================================================
--- /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/SequenceTools.java	(revision 123)
+++ /trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/SequenceTools.java	(revision 123)
@@ -0,0 +1,110 @@
+package de.ugoe.cs.eventbench.coverage;
+
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import de.ugoe.cs.eventbench.data.Event;
+import de.ugoe.cs.eventbench.models.IStochasticProcess;
+
+/**
+ * <p>
+ * This class gathers some helper functions to work with sequences.
+ * </p>
+ * 
+ * @author Steffen Herbold
+ * @version 1.0
+ */
+public class SequenceTools {
+
+	/**
+	 * <p>
+	 * Calculates the weights for all sequences passed to this function as
+	 * defined by the stochastic process and stores them in a {@link Map}. The
+	 * weights are normalized, i.e., the sum of all weights contained in this
+	 * map is 1.
+	 * </p>
+	 * 
+	 * @param process
+	 *            process used for weight calculation
+	 * @param sequences
+	 *            sequences for which the weights are calculated
+	 * @return {@link Map} of weights
+	 */
+	public static Map<List<? extends Event<?>>, Double> generateWeights(
+			IStochasticProcess process,
+			Collection<List<? extends Event<?>>> sequences) {
+		Map<List<? extends Event<?>>, Double> subSeqWeights = new LinkedHashMap<List<? extends Event<?>>, Double>();
+		double sum = 0.0;
+		for (List<? extends Event<?>> sequence : sequences) {
+			double prob = process.getProbability(sequence);
+			subSeqWeights.put(sequence, prob);
+			sum += prob;
+		}
+		if (sum < 1.0) {
+			for (Map.Entry<List<? extends Event<?>>, Double> entry : subSeqWeights
+					.entrySet()) {
+				entry.setValue(entry.getValue() / sum);
+			}
+		}
+		return subSeqWeights;
+	}
+
+	/**
+	 * <p>
+	 * Calculates the number of all existing sequences of a given length,
+	 * regardless whether they are possible or not.
+	 * </p>
+	 * 
+	 * @param process
+	 *            stochastic process whose symbols are the basis for this
+	 *            calculation
+	 * @param length
+	 *            lenght of the sequences
+	 * @return numStates^length
+	 */
+	public static long numSequences(IStochasticProcess process, int length) {
+		return (long) Math.pow(process.getNumStates(), length);
+	}
+
+	/**
+	 * <p>
+	 * Creates a {@link Set} of all subsequences of a given length that are
+	 * contained in a sequence collection.
+	 * </p>
+	 * 
+	 * @param sequences
+	 *            sequences from which the subsequences are extracted
+	 * @param length
+	 *            length of the subsequences
+	 * @return {@link Set} of all subsequences
+	 */
+	public static Set<List<? extends Event<?>>> containedSubSequences(
+			Collection<List<? extends Event<?>>> sequences, int length) {
+		Set<List<? extends Event<?>>> containedSubSeqs = new LinkedHashSet<List<? extends Event<?>>>();
+		for (List<? extends Event<?>> sequence : sequences) {
+			List<Event<?>> subSeq = new LinkedList<Event<?>>();
+			boolean minLengthReached = false;
+			for (Event<?> event : sequence) {
+				subSeq.add(event);
+				if (!minLengthReached) {
+					if (subSeq.size() == length) {
+						minLengthReached = true;
+					}
+				} else {
+					subSeq.remove(0);
+				}
+				if (minLengthReached) {
+					if (!containedSubSeqs.contains(subSeq)) {
+						containedSubSeqs.add(new LinkedList<Event<?>>(subSeq));
+					}
+				}
+			}
+		}
+		return containedSubSeqs;
+	}
+}
