Last change
on this file since 70 was
13,
checked in by sherbold, 13 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
917 bytes
|
Rev | Line | |
---|
[13] | 1 | package de.ugoe.cs.eventbench.models;
|
---|
[12] | 2 |
|
---|
| 3 | import java.util.LinkedList;
|
---|
| 4 | import java.util.List;
|
---|
| 5 | import java.util.Random;
|
---|
| 6 |
|
---|
| 7 | import de.ugoe.cs.eventbench.data.Event;
|
---|
| 8 |
|
---|
| 9 | public class HighOrderMarkovModel extends TrieBasedModel {
|
---|
| 10 |
|
---|
| 11 | public HighOrderMarkovModel(int maxOrder, Random r) {
|
---|
| 12 | super(maxOrder, r);
|
---|
| 13 | }
|
---|
| 14 |
|
---|
| 15 | @Override
|
---|
| 16 | protected double getProbability(List<Event<?>> context, Event<?> symbol) {
|
---|
| 17 | double result = 0.0d;
|
---|
| 18 |
|
---|
| 19 | List<Event<?>> contextCopy = new LinkedList<Event<?>>(context);
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | List<Event<?>> followers = trie.getFollowingSymbols(contextCopy);
|
---|
| 23 | int sumCountFollowers = 0; // N(s\sigma')
|
---|
| 24 | for( Event<?> follower : followers ) {
|
---|
| 25 | sumCountFollowers += trie.getCount(contextCopy, follower);
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | int countSymbol = trie.getCount(contextCopy, symbol);
|
---|
| 29 | if( sumCountFollowers!=0 ) {
|
---|
| 30 | result = ((double) countSymbol / sumCountFollowers);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | return result;
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.