View Javadoc
1   package org.djutils.stats.summarizers.event;
2   
3   import java.io.Serializable;
4   
5   import org.djutils.event.EventType;
6   import org.djutils.event.TimedEventType;
7   import org.djutils.metadata.MetaData;
8   import org.djutils.metadata.ObjectDescriptor;
9   
10  /**
11   * StatisticsEvents defines the standard events for statistics. <br>
12   * <br>
13   * Copyright (c) 2020-2022 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See
14   * for project information <a href="https://djutils.org" target="_blank"> https://djutils.org</a>. The DJUTILS project is
15   * distributed under a three-clause BSD-style license, which can be found at
16   * <a href="https://djutils.org/docs/license.html" target="_blank"> https://djutils.org/docs/license.html</a>. <br>
17   * @author <a href="https://www.tudelft.nl/averbraeck">Alexander Verbraeck</a>
18   * @author <a href="https://www.tudelft.nl/pknoppers">Peter Knoppers</a>
19   */
20  public final class StatisticsEvents
21  {
22  
23      /** Utility constructor. */
24      private StatisticsEvents()
25      {
26          // Utility constructor
27      }
28  
29      /**
30       * INITIALIZED_EVENT is fired whenever a statistic is (re-)initialized. The event should define the Statistic as the source
31       * and null as the content.
32       */
33      public static final EventType INITIALIZED_EVENT =
34              new EventType("INITIALIZED_EVENT", new MetaData("No arguments", "null", new ObjectDescriptor[0]));
35  
36      /**
37       * OBSERVATION_ADDED_EVENT is fired whenever an observation is processed. The event should define the Statistic as the
38       * source and the observation value as the content.
39       */
40      public static final EventType OBSERVATION_ADDED_EVENT =
41              new EventType("OBSERVATION_ADDED_EVENT", new MetaData("Ingested value", "Ingested Number value",
42                      new ObjectDescriptor("Ingested value", "Ingested Number value", Number.class)));
43  
44      /**
45       * WEIGTHED_OBSERVATION_ADDED_EVENT is fired whenever a weighted observation is processed. The event should define the
46       * Statistic as the source and an Object[] with { weight, observation_value } as the content.
47       */
48      public static final EventType WEIGHTED_OBSERVATION_ADDED_EVENT = new EventType("WEIGHTED_OBSERVATION_ADDED_EVENT",
49              new MetaData("Weight and value", "Double Weight and Double value",
50                      new ObjectDescriptor[] {new ObjectDescriptor("Weight", "Double weight", Double.class),
51                              new ObjectDescriptor("Value", "Double value", Double.class)}));
52  
53      /**
54       * OBSERVATION_ADDED_EVENT is fired whenever an observation is processed. The event should define the Statistic as the
55       * source and an Object[] with { timestamp, observation_value } as the content. This event is also fired at the end of the
56       * observations to signal the final values.
57       */
58      public static final EventType TIMESTAMPED_OBSERVATION_ADDED_EVENT = new EventType("TIMESTAMPED_OBSERVATION_ADDED_EVENT",
59              new MetaData("Time stamp and value", "Time stamp and Double value",
60                      new ObjectDescriptor[] {new ObjectDescriptor("TimeStamp", "Time stamp", Serializable.class),
61                              new ObjectDescriptor("Value", "Double value", Double.class)}));
62  
63      /* The following statistics are, e.g., used to draw graphs of the development of a statistical value. */
64  
65      /**
66       * N_EVENT is fired whenever n is updated. The event should define the Statistic as the source and the current (Long) value
67       * of n as the content.
68       */
69      public static final EventType N_EVENT = new EventType("N_EVENT", new MetaData("count", "Number of ingested events",
70              new ObjectDescriptor("eventCount", "Long event count", Long.class)));
71  
72      /**
73       * COUNT_EVENT is fired whenever there is an observation that potentially updates the count of the Counter. The event should
74       * define the Statistic as the source and the current (Long) count value as the content.
75       */
76      public static final EventType COUNT_EVENT = new EventType("COUNT_EVENT", new MetaData("count", "Number of ingested events",
77              new ObjectDescriptor("count", "Number of ingested events", Long.class)));
78  
79      /**
80       * MIN_EVENT is fired whenever there is an observation that potentially updates the lowest observed value of the statistic.
81       * The event should define the Statistic as the source and the current minimum observed value as the content.
82       */
83      public static final EventType MIN_EVENT = new EventType("MIN_EVENT", new MetaData("Minimum value", "Minimum Double value",
84              new ObjectDescriptor("Minimum value", "Minimum Double value", Double.class)));
85  
86      /**
87       * MAX_EVENT is fired whenever there is an observation that potentially updates the highest observed value of the statistic.
88       * The event should define the Statistic as the source and the current maximum observed value as the content.
89       */
90      public static final EventType MAX_EVENT = new EventType("MAX_EVENT", new MetaData("Maximum value", "Maximum Double value",
91              new ObjectDescriptor("Maximum value", "Maximum Double value", Double.class)));
92  
93      /**
94       * MEAN_EVENT is fired whenever there is an observation that potentially updates the population mean value of the statistic.
95       * The event should define the Statistic as the source and the current population mean as the content.
96       */
97      public static final EventType POPULATION_MEAN_EVENT = new EventType("POPULATION_MEAN_EVENT", new MetaData("Mean value",
98              "Mean Double value", new ObjectDescriptor("Mean value", "Mean Double value", Double.class)));
99  
100     /**
101      * VARIANCE_EVENT is fired whenever there is an observation that potentially updates the population variance of the
102      * statistic. The event should define the Statistic as the source and the current population variance as the content.
103      */
104     public static final EventType POPULATION_VARIANCE_EVENT =
105             new EventType("POPULATION_VARIANCE_EVENT", new MetaData("Variance value", "Variance Double value",
106                     new ObjectDescriptor("Variance value", "Variance Double value", Double.class)));
107 
108     /**
109      * SKEWNESS_EVENT is fired whenever there is an observation that potentially updates the population skewness of the
110      * statistic. The event should define the Statistic as the source and the current population skewness as the content.
111      */
112     public static final EventType POPULATION_SKEWNESS_EVENT =
113             new EventType("POPULATION_SKEWNESS_EVENT", new MetaData("Skewness value", "Skewness Double value",
114                     new ObjectDescriptor("Skewness value", "Skewness Double value", Double.class)));
115 
116     /**
117      * KURTOSIS_EVENT is fired whenever there is an observation that potentially updates the population kurtosis of the
118      * statistic. The event should define the Statistic as the source and the current population kurtosis as the content.
119      */
120     public static final EventType POPULATION_KURTOSIS_EVENT =
121             new EventType("POPULATION_KURTOSIS_EVENT", new MetaData("Kurtosis value", "Kurtosis Double value",
122                     new ObjectDescriptor("Kurtosis value", "Kurtosis Double value", Double.class)));
123 
124     /**
125      * EXCESS_KURTOSIS_EVENT is fired whenever there is an observation that potentially updates the population excess kurtosis
126      * of the statistic. The event should define the Statistic as the source and the current population excess kurtosis as the
127      * content.
128      */
129     public static final EventType POPULATION_EXCESS_KURTOSIS_EVENT = new EventType("POPULATION_EXCESS_KURTOSIS_EVENT",
130             new MetaData("Excess kurtosis value", "Excess kurtosis Double value",
131                     new ObjectDescriptor("Excess kurtosis value", "Excess kurtosis Double value", Double.class)));
132 
133     /**
134      * STDEV_EVENT is fired whenever there is an observation that potentially updates the population standard deviation of the
135      * statistic. The event should define the Statistic as the source and the current population standard deviation as the
136      * content.
137      */
138     public static final EventType POPULATION_STDEV_EVENT = new EventType("POPULATION_STDEV_EVENT", new MetaData("StdDev value",
139             "StdDev Double value", new ObjectDescriptor("StdDev value", "StdDev Double value", Double.class)));
140 
141     /**
142      * SUM_EVENT is fired whenever there is an observation that potentially updates the sum value of the statistic. The event
143      * should define the Statistic as the source and the current sum as the content.
144      */
145     public static final EventType SUM_EVENT = new EventType("SUM_EVENT",
146             new MetaData("Sum value", "Sum Double value", new ObjectDescriptor("Sum value", "Sum Double value", Double.class)));
147 
148     /**
149      * SAMPLE_MEAN_EVENT is fired whenever there is an observation that potentially updates the sample mean value of the
150      * statistic. The event should define the Statistic as the source and the current sample mean as the content.
151      */
152     public static final EventType SAMPLE_MEAN_EVENT = new EventType("SAMPLE_MEAN_EVENT", new MetaData("Sample mean value",
153             "Sample mean Double value", new ObjectDescriptor("Sample mean value", "Sample mean Double value", Double.class)));
154 
155     /**
156      * SAMPLE_VARIANCE_EVENT is fired whenever there is an observation that potentially updates the sample variance of the
157      * statistic. The event should define the Statistic as the source and the current sample variance as the content.
158      */
159     public static final EventType SAMPLE_VARIANCE_EVENT =
160             new EventType("SAMPLE_VARIANCE_EVENT", new MetaData("Sample variance value", "Sample variance Double value",
161                     new ObjectDescriptor("Sample variance value", "Sample variance Double value", Double.class)));
162 
163     /**
164      * SAMPLE_SKEWNESS_EVENT is fired whenever there is an observation that potentially updates the sample skewness of the
165      * statistic. The event should define the Statistic as the source and the current sample skewness as the content.
166      */
167     public static final EventType SAMPLE_SKEWNESS_EVENT =
168             new EventType("SAMPLE_SKEWNESS_EVENT", new MetaData("Sample skewness value", "Sample skewness Double value",
169                     new ObjectDescriptor("Sample skewness value", "Sample skewness Double value", Double.class)));
170 
171     /**
172      * SAMPLE_KURTOSIS_EVENT is fired whenever there is an observation that potentially updates the sample kurtosis of the
173      * statistic. The event should define the Statistic as the source and the current sample kurtosis as the content.
174      */
175     public static final EventType SAMPLE_KURTOSIS_EVENT =
176             new EventType("SAMPLE_KURTOSIS_EVENT", new MetaData("Sample kurtosis value", "Sample kurtosis Double value",
177                     new ObjectDescriptor("sample kurtosis value", "Sample kurtosis Double value", Double.class)));
178 
179     /**
180      * SAMPLE_KURTOSIS_EVENT is fired whenever there is an observation that potentially updates the sample excess kurtosis of
181      * the statistic. The event should define the Statistic as the source and the current sample excess kurtosis as the content.
182      */
183     public static final EventType SAMPLE_EXCESS_KURTOSIS_EVENT = new EventType("SAMPLE_EXCESS_KURTOSIS_EVENT",
184             new MetaData("Sample excess kurtosis value", "Sample excess kurtosis Double value",
185                     new ObjectDescriptor("Sample excess kurtosis value", "Sample excess kurtosis Double value", Double.class)));
186 
187     /**
188      * SAMPLE_STDEV_EVENT is fired whenever there is an observation that potentially updates the sample standard deviation of
189      * the statistic. The event should define the Statistic as the source and the current sample standard deviation as the
190      * content.
191      */
192     public static final EventType SAMPLE_STDEV_EVENT =
193             new EventType("SAMPLE_STDEV_EVENT", new MetaData("Sample stdDev value", "Sample stdDev Double value",
194                     new ObjectDescriptor("Sample stdDev value", "Sample stdDev Double value", Double.class)));
195 
196     /**
197      * WEIGHTED_MEAN_EVENT is fired whenever there is an observation that potentially updates the weighted population mean value
198      * of the statistic. The event should define the Statistic as the source and the current weighted population mean as the
199      * content.
200      */
201     public static final EventType WEIGHTED_POPULATION_MEAN_EVENT = new EventType("WEIGHTED_POPULATION_MEAN_EVENT", new MetaData(
202             "Weighted population mean value", "Weighed population mean Double value",
203             new ObjectDescriptor("Weighted population mean value", "Weighted population mean Double value", Double.class)));
204 
205     /**
206      * WEIGHTED_VARIANCE_EVENT is fired whenever there is an observation that potentially updates the weighted population
207      * variance of the statistic. The event should define the Statistic as the source and the current weighted population
208      * variance as the content.
209      */
210     public static final EventType WEIGHTED_POPULATION_VARIANCE_EVENT = new EventType("WEIGHTED_POPULATION_VARIANCE_EVENT",
211             new MetaData("Weighted population variance value", "Weighted population variance Double value",
212                     new ObjectDescriptor("Weighted population variance value", "Weighted population variance Double value",
213                             Double.class)));
214 
215     /**
216      * WEIGHTED_STDEV_EVENT is fired whenever there is an observation that potentially updates the weighted population standard
217      * deviation of the statistic. The event should define the Statistic as the source and the current weighted population
218      * standard deviation as the content.
219      */
220     public static final EventType WEIGHTED_POPULATION_STDEV_EVENT =
221             new EventType("WEIGHTED_POPULATION_STDEV_EVENT",
222                     new MetaData("Weighted population stdDev value", "Weighted population stdDev Double value",
223                             new ObjectDescriptor("Weighted population stdDev value", "Weighted population stdDev Double value",
224                                     Double.class)));
225 
226     /**
227      * WEIGHTED_SUM_EVENT is fired whenever there is an observation that potentially updates the weighted sum value of the
228      * statistic. The event should define the Statistic as the source and the current weighted sum as the content.
229      */
230     public static final EventType WEIGHTED_SUM_EVENT =
231             new EventType("WEIGHTED_SUM_EVENT", new MetaData("Weighted sum value", "Weighted sum Double value",
232                     new ObjectDescriptor("Weighted sum value", "Weighted sum Double value", Double.class)));
233 
234     /**
235      * WEIGHTED_SAMPLE_MEAN_EVENT is fired whenever there is an observation that potentially updates the weighted sample mean
236      * value of the statistic. The event should define the Statistic as the source and the current weighted sample mean as the
237      * content.
238      */
239     public static final EventType WEIGHTED_SAMPLE_MEAN_EVENT = new EventType("WEIGHTED_SAMPLE_MEAN_EVENT",
240             new MetaData("Weighted sample mean value", "Weighted sample mean Double value",
241                     new ObjectDescriptor("Weighted sample mean value", "Weighted sample mean Double value", Double.class)));
242 
243     /**
244      * WEIGHTED_SAMPLE_VARIANCE_EVENT is fired whenever there is an observation that potentially updates the weighted sample
245      * variance of the statistic. The event should define the Statistic as the source and the current weighted sample variance
246      * as the content.
247      */
248     public static final EventType WEIGHTED_SAMPLE_VARIANCE_EVENT = new EventType("WEIGHTED_SAMPLE_VARIANCE_EVENT", new MetaData(
249             "Weighted sample variance value", "Weighted sample variance Double value",
250             new ObjectDescriptor("Weighted sample variance value", "Weighted sample variance Double value", Double.class)));
251 
252     /**
253      * WEIGHTED_SAMPLE_STDEV_EVENT is fired whenever there is an observation that potentially updates the weighted sample
254      * standard deviation of the statistic. The event should define the Statistic as the source and the current weighted sample
255      * standard deviation as the content.
256      */
257     public static final EventType WEIGHTED_SAMPLE_STDEV_EVENT = new EventType("WEIGHTED_SAMPLE_STDEV_EVENT",
258             new MetaData("Weighted sample stdDev value", "Weighted sample stdDev Double value",
259                     new ObjectDescriptor("Weighted sample stdDev value", "Weighted sample stdDev Double value", Double.class)));
260 
261     /* ********************* TIMESTANPED VERSIONS OF EVENTS FOR THE TIMESTAMPWEIGHTEDTALLY ************************ */
262 
263     /**
264      * TIMED_N_EVENT is fired whenever n is updated. The event should define the Statistic as the source and the current (Long)
265      * value of n as the content.
266      */
267     public static final TimedEventType TIMED_N_EVENT = new TimedEventType("TIMED_N_EVENT", new MetaData("count",
268             "Number of ingested events", new ObjectDescriptor("eventCount", "Long event count", Long.class)));
269 
270     /**
271      * TIMED_MIN_EVENT is fired whenever there is an observation that potentially updates the lowest observed value of the
272      * statistic. The event should define the Statistic as the source and the current minimum observed value as the content.
273      */
274     public static final TimedEventType TIMED_MIN_EVENT = new TimedEventType("TIMED_MIN_EVENT", new MetaData("Minimum value",
275             "Minimum Double value", new ObjectDescriptor("Minimum value", "Minimum Double value", Double.class)));
276 
277     /**
278      * TIMED_MAX_EVENT is fired whenever there is an observation that potentially updates the highest observed value of the
279      * statistic. The event should define the Statistic as the source and the current maximum observed value as the content.
280      */
281     public static final TimedEventType TIMED_MAX_EVENT = new TimedEventType("TIMED_MAX_EVENT", new MetaData("Maximum value",
282             "Maximum Double value", new ObjectDescriptor("Maximum value", "Maximum Double value", Double.class)));
283 
284     /**
285      * TIMED_WEIGHTED_MEAN_EVENT is fired whenever there is an observation that potentially updates the weighted population mean
286      * value of the statistic. The event should define the Statistic as the source and the current weighted population mean as
287      * the content.
288      */
289     public static final TimedEventType TIMED_WEIGHTED_POPULATION_MEAN_EVENT =
290             new TimedEventType("TIMED_WEIGHTED_POPULATION_MEAN_EVENT",
291                     new MetaData("Weighted population mean value", "Weighed population mean Double value", new ObjectDescriptor(
292                             "Weighted population mean value", "Weighted population mean Double value", Double.class)));
293 
294     /**
295      * TIMED_WEIGHTED_VARIANCE_EVENT is fired whenever there is an observation that potentially updates the weighted population
296      * variance of the statistic. The event should define the Statistic as the source and the current weighted population
297      * variance as the content.
298      */
299     public static final TimedEventType TIMED_WEIGHTED_POPULATION_VARIANCE_EVENT =
300             new TimedEventType("TIMED_WEIGHTED_POPULATION_VARIANCE_EVENT",
301                     new MetaData("Weighted population variance value", "Weighted population variance Double value",
302                             new ObjectDescriptor("Weighted population variance value",
303                                     "Weighted population variance Double value", Double.class)));
304 
305     /**
306      * TIMED_WEIGHTED_STDEV_EVENT is fired whenever there is an observation that potentially updates the weighted population
307      * standard deviation of the statistic. The event should define the Statistic as the source and the current weighted
308      * population standard deviation as the content.
309      */
310     public static final TimedEventType TIMED_WEIGHTED_POPULATION_STDEV_EVENT =
311             new TimedEventType("TIMED_WEIGHTED_POPULATION_STDEV_EVENT",
312                     new MetaData("Weighted population stdDev value", "Weighted population stdDev Double value",
313                             new ObjectDescriptor("Weighted population stdDev value", "Weighted population stdDev Double value",
314                                     Double.class)));
315 
316     /**
317      * TIMED_WEIGHTED_SUM_EVENT is fired whenever there is an observation that potentially updates the weighted sum value of the
318      * statistic. The event should define the Statistic as the source and the current weighted sum as the content.
319      */
320     public static final TimedEventType TIMED_WEIGHTED_SUM_EVENT =
321             new TimedEventType("TIMED_WEIGHTED_SUM_EVENT", new MetaData("Weighted sum value", "Weighted sum Double value",
322                     new ObjectDescriptor("Weighted sum value", "Weighted sum Double value", Double.class)));
323 
324     /**
325      * TIMED_WEIGHTED_SAMPLE_MEAN_EVENT is fired whenever there is an observation that potentially updates the weighted sample
326      * mean value of the statistic. The event should define the Statistic as the source and the current weighted sample mean as
327      * the content.
328      */
329     public static final TimedEventType TIMED_WEIGHTED_SAMPLE_MEAN_EVENT = new TimedEventType("TIMED_WEIGHTED_SAMPLE_MEAN_EVENT",
330             new MetaData("Weighted sample mean value", "Weighted sample mean Double value",
331                     new ObjectDescriptor("Weighted sample mean value", "Weighted sample mean Double value", Double.class)));
332 
333     /**
334      * TIMED_WEIGHTED_SAMPLE_VARIANCE_EVENT is fired whenever there is an observation that potentially updates the weighted
335      * sample variance of the statistic. The event should define the Statistic as the source and the current weighted sample
336      * variance as the content.
337      */
338     public static final TimedEventType TIMED_WEIGHTED_SAMPLE_VARIANCE_EVENT =
339             new TimedEventType("TIMED_WEIGHTED_SAMPLE_VARIANCE_EVENT",
340                     new MetaData("Weighted sample variance value", "Weighted sample variance Double value",
341                             new ObjectDescriptor("Weighted sample variance value", "Weighted sample variance Double value",
342                                     Double.class)));
343 
344     /**
345      * TIMED_WEIGHTED_SAMPLE_STDEV_EVENT is fired whenever there is an observation that potentially updates the weighted sample
346      * standard deviation of the statistic. The event should define the Statistic as the source and the current weighted sample
347      * standard deviation as the content.
348      */
349     public static final TimedEventType TIMED_WEIGHTED_SAMPLE_STDEV_EVENT = new TimedEventType(
350             "TIMED_WEIGHTED_SAMPLE_STDEV_EVENT",
351             new MetaData("Weighted sample stdDev value", "Weighted sample stdDev Double value",
352                     new ObjectDescriptor("Weighted sample stdDev value", "Weighted sample stdDev Double value", Double.class)));
353 
354 }