1 | package de.ugoe.cs.quest.usageprofiles;
|
---|
2 |
|
---|
3 | import java.io.Serializable;
|
---|
4 | import java.security.InvalidParameterException;
|
---|
5 | import java.util.Collection;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.quest.eventcore.Event;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * <p>
|
---|
12 | * This interface defines the functionalities provided by stochastic processes.
|
---|
13 | * </p>
|
---|
14 | *
|
---|
15 | * @author Steffen Herbold
|
---|
16 | * @version 1.0
|
---|
17 | */
|
---|
18 | public interface IStochasticProcess extends Serializable {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * <p>
|
---|
22 | * Returns the probability, that the next event is {@code symbol} given the last events are
|
---|
23 | * {@code context}. The last element of {@code context} is the most recent in the history, the
|
---|
24 | * first element is the oldest.
|
---|
25 | * </p>
|
---|
26 | *
|
---|
27 | * @param context
|
---|
28 | * recently observed symbols
|
---|
29 | * @param symbol
|
---|
30 | * event for which the probability is calculated
|
---|
31 | * @return probabilty the {@code symbol} is the next event, given the last events
|
---|
32 | * {@code context}
|
---|
33 | * @throws InvalidParameterException
|
---|
34 | * thrown if context or symbol is null
|
---|
35 | */
|
---|
36 | double getProbability(List<Event> context, Event symbol);
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * <p>
|
---|
40 | * Returns the probabilitiy that a given sequence is generated by the stochastic process.
|
---|
41 | * </p>
|
---|
42 | *
|
---|
43 | * @param sequence
|
---|
44 | * sequences of which the probability is calculated
|
---|
45 | * @return probability of the sequences; 1.0 if sequence is empty or null
|
---|
46 | * @throws InvalidParameterException
|
---|
47 | * thrown if sequence is null
|
---|
48 | */
|
---|
49 | double getProbability(List<Event> sequence);
|
---|
50 |
|
---|
51 | /**
|
---|
52 | * <p>
|
---|
53 | * Generates a random sequence of events. The sequence starts with {@link Event#STARTEVENT} and
|
---|
54 | * finishes with {@link Event#ENDEVENT}.
|
---|
55 | * </p>
|
---|
56 | *
|
---|
57 | * @return randomly generated sequence
|
---|
58 | */
|
---|
59 | public List<Event> randomSequence();
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * <p>
|
---|
63 | * Generates a random sequence of events. The sequence starts with {@link Event#STARTEVENT} and
|
---|
64 | * finishes with
|
---|
65 | * <ul>
|
---|
66 | * <li>{@link Event#ENDEVENT} if validEnd==true.</li>
|
---|
67 | * <li>b) if a generated sequences reaches {@link Event#ENDEVENT} before maxLength, the sequence
|
---|
68 | * finishes and is shorter than maxLenght. Otherwise, the sequence finishes as soon as maxLength
|
---|
69 | * is reached and the final event of the sequence must not be {@link Event#ENDEVENT}.</li>
|
---|
70 | * </ul>
|
---|
71 | * </p>
|
---|
72 | *
|
---|
73 | * @param maxLength
|
---|
74 | * maximum length of the generated sequence
|
---|
75 | * @param validEnd
|
---|
76 | * if true, only sequences that finish with {@link Event#ENDEVENT} are generated
|
---|
77 | * @return randomly generated sequence
|
---|
78 | *
|
---|
79 | */
|
---|
80 | public List<Event> randomSequence(int maxLength, boolean validEnd);
|
---|
81 |
|
---|
82 | /**
|
---|
83 | * <p>
|
---|
84 | * Generates all sequences of a given length are possible, i.e., have a positive probability.<br>
|
---|
85 | * All states are used as possible starting states.
|
---|
86 | * </p>
|
---|
87 | *
|
---|
88 | * @param length
|
---|
89 | * length of the generated sequences
|
---|
90 | * @return generated sequences
|
---|
91 | * @see #generateSequences(int, boolean)
|
---|
92 | * @throws InvalidParameterException
|
---|
93 | * thrown if length is less than or equal to 0
|
---|
94 | */
|
---|
95 | public Collection<List<Event>> generateSequences(int length);
|
---|
96 |
|
---|
97 | /**
|
---|
98 | * <p>
|
---|
99 | * Generates all sequences of given length that can are possible, i.e., have positive
|
---|
100 | * probability.<br>
|
---|
101 | * If {@code fromStart==true}, all generated sequences start in {@link Event#STARTEVENT}.
|
---|
102 | * Otherwise this method is the same as {@link #generateSequences(int)}.
|
---|
103 | * </p>
|
---|
104 | *
|
---|
105 | * @param length
|
---|
106 | * length of the generated sequences
|
---|
107 | * @param fromStart
|
---|
108 | * if true, all generated sequences start with {@link Event#STARTEVENT}
|
---|
109 | * @return generated sequences
|
---|
110 | * @throws InvalidParameterException
|
---|
111 | * thrown if length is less than or equal to 0
|
---|
112 | */
|
---|
113 | public Collection<List<Event>> generateSequences(int length, boolean fromStart);
|
---|
114 |
|
---|
115 | /**
|
---|
116 | * <p>
|
---|
117 | * Generates all sequences starting with {@link Event#STARTEVENT} and finishing with
|
---|
118 | * {@link Event#ENDEVENT} of a given length. It is possible that no such sequence exists with
|
---|
119 | * the defined length and the returned set is empty. If {@code length} is less than 2 the
|
---|
120 | * returned set is always empty.
|
---|
121 | * </p>
|
---|
122 | *
|
---|
123 | * @param length
|
---|
124 | * @return generated sequences
|
---|
125 | * @throws InvalidParameterException
|
---|
126 | * thrown if length is less than or equal to 0
|
---|
127 | */
|
---|
128 | public Collection<List<Event>> generateValidSequences(int length);
|
---|
129 |
|
---|
130 | /**
|
---|
131 | * <p>
|
---|
132 | * Returns the number of states known by the stochastic process, i.e., the size of its alphabet.
|
---|
133 | * </p>
|
---|
134 | *
|
---|
135 | * @return number of states
|
---|
136 | */
|
---|
137 | public int getNumSymbols();
|
---|
138 |
|
---|
139 | /**
|
---|
140 | * <p>
|
---|
141 | * Returns a string representation of all known states.
|
---|
142 | * </p>
|
---|
143 | *
|
---|
144 | * @return string representation for all known states
|
---|
145 | */
|
---|
146 | public String[] getSymbolStrings();
|
---|
147 |
|
---|
148 | /**
|
---|
149 | * <p>
|
---|
150 | * Returns the number of states the process would have if it would be flattened through
|
---|
151 | * state-splitting to a first-order Markov model.
|
---|
152 | * </p>
|
---|
153 | * <p>
|
---|
154 | * If it is not possible to flatten the model, -1 is returned.
|
---|
155 | * </p>
|
---|
156 | *
|
---|
157 | * @return number of states an equivalent FOM would have; -1 if not available
|
---|
158 | */
|
---|
159 | public int getNumFOMStates();
|
---|
160 |
|
---|
161 | /**
|
---|
162 | * <p>
|
---|
163 | * Returns the number of transitions the process would have if it would be flattened through
|
---|
164 | * state-splitting to a first-order Markov model.
|
---|
165 | * </p>
|
---|
166 | *
|
---|
167 | * @return number of transitions an equivalent FOM would have; -1 if not available
|
---|
168 | */
|
---|
169 | public int getNumTransitions();
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * <p>
|
---|
173 | * Returns all states known by the stochastic process, i.e., its {@link Event}s.
|
---|
174 | * </p>
|
---|
175 | *
|
---|
176 | * @return events known by the process
|
---|
177 | */
|
---|
178 | public Collection<Event> getEvents();
|
---|
179 |
|
---|
180 | }
|
---|