Changeset 80 for trunk/EventBenchCore/src/de/ugoe/cs/eventbench
- Timestamp:
- 06/22/11 14:12:18 (14 years ago)
- Location:
- trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/HighOrderMarkovModel.java
r13 r80 12 12 super(maxOrder, r); 13 13 } 14 14 15 15 @Override 16 p rotecteddouble getProbability(List<Event<?>> context, Event<?> symbol) {16 public double getProbability(List<Event<?>> context, Event<?> symbol) { 17 17 double result = 0.0d; 18 18 19 List<Event<?>> contextCopy = new LinkedList<Event<?>>(context); 19 List<Event<?>> contextCopy; 20 if( context.size()>=trieOrder ) { 21 contextCopy = new LinkedList<Event<?>>(context.subList(context.size()-trieOrder+1, context.size())); 22 } else { 23 contextCopy = new LinkedList<Event<?>>(context); 24 } 20 25 21 26 -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java
r70 r80 2 2 3 3 import java.util.List; 4 import java.util.Set; 4 5 5 6 import de.ugoe.cs.eventbench.data.Event; 6 7 7 8 public interface IStochasticProcess { 9 10 double getProbability(List<Event<?>> context, Event<?> symbol); 8 11 9 12 public List<? extends Event<?>> randomSequence(); … … 12 15 13 16 public String[] getStateStrings(); 17 18 public Set<Event<?>> getEvents(); 14 19 15 20 } -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java
r22 r80 29 29 30 30 @Override 31 p rotecteddouble getProbability(List<Event<?>> context, Event<?> symbol) {31 public double getProbability(List<Event<?>> context, Event<?> symbol) { 32 32 double result = 0.0d; 33 33 double resultCurrentContex = 0.0d; 34 34 double resultShorterContex = 0.0d; 35 35 36 List<Event<?>> contextCopy = new LinkedList<Event<?>>(context); // defensive copy 36 List<Event<?>> contextCopy; 37 if( context.size()>=trieOrder ) { 38 contextCopy = new LinkedList<Event<?>>(context.subList(context.size()-trieOrder+1, context.size())); 39 } else { 40 contextCopy = new LinkedList<Event<?>>(context); 41 } 37 42 38 43 … … 47 52 resultCurrentContex = ((double) countSymbol) / sumCountFollowers; 48 53 } else { 49 resultCurrentContex = ((double) countSymbol / sumCountFollowers)*(1-probEscape); 54 if( sumCountFollowers==0 ) { 55 resultCurrentContex = 0.0; 56 } 57 else { 58 resultCurrentContex = ((double) countSymbol / sumCountFollowers)*(1-probEscape); 59 } 50 60 contextCopy.remove(0); 51 61 double probSuffix = getProbability(contextCopy, symbol); -
trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java
r70 r80 4 4 import java.util.List; 5 5 import java.util.Random; 6 import java.util.Set; 6 7 7 8 import de.ugoe.cs.eventbench.data.Event; … … 13 14 14 15 protected int trieOrder; 15 16 protected abstract double getProbability(List<Event<?>> context, Event<?> symbol);17 16 18 17 protected Trie<Event<?>> trie; … … 99 98 return stateStrings; 100 99 } 100 101 public Set<Event<?>> getEvents() { 102 return trie.getKnownSymbols(); 103 } 101 104 102 105 }
Note: See TracChangeset
for help on using the changeset viewer.