Ignore:
Timestamp:
07/12/11 16:52:27 (13 years ago)
Author:
sherbold
Message:

+ extended de.ugoe.cs.eventbench.models.IStochasticProcess with getProbability() for a sequence

  • refactored de.ugoe.cs.eventbench.coverage.CoverageCalculator? to use IStochasticProcess#getProbability(sequences)
Location:
trunk/EventBenchCore/src/de/ugoe/cs/eventbench
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/coverage/CoverageCalculator.java

    r114 r118  
    178178                double sum = 0.0; 
    179179                for (List<? extends Event<?>> sequence : sequences) { 
    180                         double prob = 1.0; 
    181                         List<Event<?>> context = new LinkedList<Event<?>>(); 
    182                         for (Event<?> event : sequence) { 
    183                                 prob *= process.getProbability(context, event); 
    184                                 context.add(event); 
    185                         } 
     180                        double prob = process.getProbability(sequence); 
    186181                        subSeqWeights.put(sequence, prob); 
    187182                        sum += prob; 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/IStochasticProcess.java

    r102 r118  
    3232         */ 
    3333        double getProbability(List<? extends Event<?>> context, Event<?> symbol); 
     34         
     35        /** 
     36         * <p> 
     37         * Returns the probabilitiy that a given sequence is generated by the stochastic process. 
     38         * </p> 
     39         * @param sequence sequences of which the probability is calculated 
     40         * @return probability of the sequences; 1.0 if sequence is empty or null 
     41         */ 
     42        double getProbability(List<? extends Event<?>> sequence); 
    3443 
    3544        /** 
  • trunk/EventBenchCore/src/de/ugoe/cs/eventbench/models/TrieBasedModel.java

    r102 r118  
    274274         */ 
    275275        @Override 
    276         public Collection<List<? extends Event<?>>> generateValidSequences(int length) { 
     276        public Collection<List<? extends Event<?>>> generateValidSequences( 
     277                        int length) { 
    277278                // check for min-length implicitly done by generateSequences 
    278                 Collection<List<? extends Event<?>>> allSequences = generateSequences(length, 
    279                                 true); 
     279                Collection<List<? extends Event<?>>> allSequences = generateSequences( 
     280                                length, true); 
    280281                Collection<List<? extends Event<?>>> validSequences = new LinkedHashSet<List<? extends Event<?>>>(); 
    281282                for (List<? extends Event<?>> sequence : allSequences) { 
     
    288289        } 
    289290 
     291        /* 
     292         * (non-Javadoc) 
     293         *  
     294         * @see 
     295         * de.ugoe.cs.eventbench.models.IStochasticProcess#getProbability(java.util 
     296         * .List) 
     297         */ 
     298        @Override 
     299        public double getProbability(List<? extends Event<?>> sequence) { 
     300                double prob = 1.0; 
     301                if (sequence != null) { 
     302                        List<Event<?>> context = new LinkedList<Event<?>>(); 
     303                        for (Event<?> event : sequence) { 
     304                                prob *= getProbability(context, event); 
     305                                context.add(event); 
     306                        } 
     307                } 
     308                return prob; 
     309        } 
     310 
    290311} 
Note: See TracChangeset for help on using the changeset viewer.