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