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