Last change
on this file since 92 was
92,
checked in by sherbold, 13 years ago
|
- added deterministic finite automata as possible model
|
-
Property svn:mime-type set to
text/plain
|
File size:
983 bytes
|
Rev | Line | |
---|
[92] | 1 | package de.ugoe.cs.eventbench.models;
|
---|
| 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 DeterministicFiniteAutomaton extends FirstOrderMarkovModel {
|
---|
| 10 |
|
---|
| 11 | /**
|
---|
| 12 | * Id for object serialization.
|
---|
| 13 | */
|
---|
| 14 | private static final long serialVersionUID = 1L;
|
---|
| 15 |
|
---|
| 16 | public DeterministicFiniteAutomaton(Random r) {
|
---|
| 17 | super(r);
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | @Override
|
---|
| 21 | public double getProbability(List<Event<?>> context, Event<?> symbol) {
|
---|
| 22 | double result = 0.0d;
|
---|
| 23 |
|
---|
| 24 | List<Event<?>> contextCopy;
|
---|
| 25 | if( context.size()>=trieOrder ) {
|
---|
| 26 | contextCopy = new LinkedList<Event<?>>(context.subList(context.size()-trieOrder+1, context.size()));
|
---|
| 27 | } else {
|
---|
| 28 | contextCopy = new LinkedList<Event<?>>(context);
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 |
|
---|
| 32 | List<Event<?>> followers = trie.getFollowingSymbols(contextCopy);
|
---|
| 33 |
|
---|
| 34 | if( followers.size()!=0 && followers.contains(symbol) ) {
|
---|
| 35 | result = 1.0d / followers.size();
|
---|
| 36 | }
|
---|
| 37 |
|
---|
| 38 | return result;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.