Changeset 1641
- Timestamp:
- 08/01/14 15:48:23 (10 years ago)
- 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 51 51 /** 52 52 * <p> 53 * Returns the probabilit iy that a given sequence is generated by the stochastic process.53 * Returns the probability that a given sequence is generated by the stochastic process. 54 54 * </p> 55 55 * 56 56 * @param sequence 57 57 * sequences of which the probability is calculated 58 * @return probability of the sequences; 1.0 if sequence is empty or null58 * @return probability of the sequences; 1.0 if sequence is empty 59 59 * @throws IllegalArgumentException 60 60 * thrown if sequence is null 61 61 */ 62 62 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); 63 76 64 77 /** -
trunk/autoquest-core-usageprofiles/src/main/java/de/ugoe/cs/autoquest/usageprofiles/TrieBasedModel.java
r927 r1641 314 314 if (length < 1) { 315 315 throw new IllegalArgumentException( 316 316 "Length of generated subsequences must be at least 1."); 317 317 } 318 318 if (length == 1) { … … 388 388 * (non-Javadoc) 389 389 * 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 * 390 409 * @see de.ugoe.cs.autoquest.usageprofiles.IStochasticProcess#getNumFOMStates() 391 410 */
Note: See TracChangeset
for help on using the changeset viewer.