Changeset 1641 for trunk


Ignore:
Timestamp:
08/01/14 15:48:23 (10 years ago)
Author:
sherbold
Message:
  • added method getLogSum to the interface IStochasticProcess and implemented it in the TrieBasedModel?
Location:
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/IStochasticProcess.java

    r927 r1641  
    5151    /** 
    5252     * <p> 
    53      * Returns the probabilitiy that a given sequence is generated by the stochastic process. 
     53     * Returns the probability that a given sequence is generated by the stochastic process. 
    5454     * </p> 
    5555     *  
    5656     * @param sequence 
    5757     *            sequences of which the probability is calculated 
    58      * @return probability of the sequences; 1.0 if sequence is empty or null 
     58     * @return probability of the sequences; 1.0 if sequence is empty 
    5959     * @throws IllegalArgumentException 
    6060     *             thrown if sequence is null 
    6161     */ 
    6262    double getProbability(List<Event> sequence); 
     63     
     64    /** 
     65     * <p> 
     66     * Returns the sum of the negative logarithm of the probabilities.  
     67     * </p> 
     68     * 
     69     * @param sequence 
     70     *            sequences of which the logsum is calculated 
     71     * @return logsum of the sequences; 0.0 if sequence is empty 
     72     * @throws IllegalArgumentException 
     73     *             thrown if sequence is null 
     74     */ 
     75    public double getLogSum(List<Event> sequence); 
    6376 
    6477    /** 
  • trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieBasedModel.java

    r927 r1641  
    314314        if (length < 1) { 
    315315            throw new IllegalArgumentException( 
    316                                                 "Length of generated subsequences must be at least 1."); 
     316                                               "Length of generated subsequences must be at least 1."); 
    317317        } 
    318318        if (length == 1) { 
     
    388388     * (non-Javadoc) 
    389389     *  
     390     * @see de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess#getProbability(java.util .List) 
     391     */ 
     392    @Override 
     393    public double getLogSum(List<Event> sequence) { 
     394        if (sequence == null) { 
     395            throw new IllegalArgumentException("sequence must not be null"); 
     396        } 
     397        double odds = 0.0; 
     398        List<Event> context = new LinkedList<Event>(); 
     399        for (Event event : sequence) { 
     400            odds -= Math.log(getProbability(context, event)); 
     401            context.add(event); 
     402        } 
     403        return odds; 
     404    } 
     405 
     406    /* 
     407     * (non-Javadoc) 
     408     *  
    390409     * @see de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess#getNumFOMStates() 
    391410     */ 
Note: See TracChangeset for help on using the changeset viewer.