Browse files

started to add the markov chain analysis method not completed at this…

… time but it is without errors

git-svn-id: bcaee279-2e94-4b2e-be96-a1d7c6f3fc26
  • Loading branch information...
dvescovi committed Jan 6, 2011
1 parent f195d08 commit 0e255ab89fc64b934583a841ccd30b942b2bc267
Showing with 98 additions and 4 deletions.
  1. +1 −3 .classpath
  2. +1 −1 .project
  3. +96 −0 src/com/jgaap/classifiers/
@@ -2,9 +2,6 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="unittests"/>
<classpathentry kind="src" path="util"/>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="lib/external/abbot.jar"/>
<classpathentry kind="lib" path="lib/external/ant.jar"/>
<classpathentry kind="lib" path="lib/external/bcmail-jdk14-132.jar"/>
@@ -26,5 +23,6 @@
<classpathentry kind="lib" path="lib/external/poi-ooxml-3.5-beta3-20080926.jar"/>
<classpathentry kind="lib" path="lib/external/poi-scratchpad-3.5-beta3-20080926.jar"/>
<classpathentry kind="lib" path="lib/external/json_simple-1.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
@@ -0,0 +1,96 @@
package com.jgaap.classifiers;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import com.jgaap.generics.AnalysisDriver;
import com.jgaap.generics.Event;
import com.jgaap.generics.EventSet;
import com.jgaap.generics.Pair;
* @author Darren Vescovi
public class MarkovChainAnalysis extends AnalysisDriver{
public String displayName() {
return "Markov Chain Analysis";
public boolean showInGUI() {
return true;
public String tooltipText() {
return "First Order Markov Chain Analysis";
public List<Pair<String, Double>> analyze(EventSet unknown, List<EventSet> known) {
List<Pair<String, Double>> results = new ArrayList<Pair<String, Double>>();
Iterator<EventSet> setIt = known.iterator();
Hashtable<Event, Hashtable<Event, Double>> matrix = new Hashtable<Event, Hashtable<Event, Double>>();
EventSet ev =;
//Iterate over events to create a matrix with
//counts of each time a event pair sequence
Iterator<Event> eventIt = ev.iterator();
//get the first event
Event e1 =;
//get the next event
Event e2 =;
//find out if the event sequence is already in the matrix
//if so increment the count by 1;
double tmp = matrix.get(e1).get(e2).doubleValue();
matrix.get(e1).put(e2, new Double(tmp+1));
//add the new sequence provided the first event is already
//in the matrix
matrix.get(e1).put(e2, new Double(1));
//add the new sequence to matrix
matrix.put(e1, new Hashtable<Event, Double>());
matrix.get(e1).put(e2, new Double(1));
//reassign e1 to be e2
return null;//TODO make this return something

0 comments on commit 0e255ab

Please sign in to comment.