source: trunk/quest-core-usageprofiles/src/main/java/de/ugoe/cs/quest/usageprofiles/IStochasticProcess.java @ 559

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