Ignore:
Timestamp:
06/22/11 14:12:18 (13 years ago)
Author:
sherbold
Message:
  • added getProbability() to de.ugoe.cs.eventbench.models.IStochasticProcess and implementing classes
  • added getEvents() to de.ugoe.cs.eventbench.models.IStochasticProcess and implementing classes
  • changed getProbability() of subclasses of de.ugoe.cs.eventbench.TrieBasedModel? such that the probability is not zero if the context length is higher than the order of the model, but rather the probability of the suffix of the length of the order, i.e., for a 2nd-order model context(X1,X2,X3,X4) becomes context(X3,X4)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/PredictionByPartialMatch.java

    r22 r80  
    2929         
    3030        @Override 
    31         protected double getProbability(List<Event<?>> context, Event<?> symbol) { 
     31        public double getProbability(List<Event<?>> context, Event<?> symbol) { 
    3232                double result = 0.0d; 
    3333                double resultCurrentContex = 0.0d; 
    3434                double resultShorterContex = 0.0d; 
    3535                 
    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                } 
    3742 
    3843         
     
    4752                        resultCurrentContex = ((double) countSymbol) / sumCountFollowers; 
    4853                } 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                        } 
    5060                        contextCopy.remove(0);  
    5161                        double probSuffix = getProbability(contextCopy, symbol); 
Note: See TracChangeset for help on using the changeset viewer.