Package org.djutils.stats.summarizers
Class TimestampWeightedTally
java.lang.Object
org.djutils.stats.summarizers.WeightedTally
org.djutils.stats.summarizers.TimestampWeightedTally
- All Implemented Interfaces:
Serializable
,Statistic
,TallyStatistic
- Direct Known Subclasses:
EventBasedTimestampWeightedTally
The TimestampWeightedTally class defines a time-weighted tally based on timestamped data. The difference with a normal
time-weighed tally is that the weight of a value is only known at the occurrence of the next timestamp. Furthermore, a last
timestamp needs to be specified to determine the weight of the last value. Timestamps can be Number based or Calendar based.
Copyright (c) 2020-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://simulation.tudelft.nl/dsol/3.0/license.html.
- Author:
- Alexander Verbraeck
- See Also:
-
Field Summary
Fields inherited from class org.djutils.stats.summarizers.WeightedTally
semaphore
-
Constructor Summary
ConstructorDescriptionTimestampWeightedTally
(String description) constructs a new TimestampWeightedTally with a description. -
Method Summary
Modifier and TypeMethodDescriptionvoid
endObservations
(Number timestamp) End the observations and closes the last interval of observations.void
endObservations
(Calendar timestamp) End the observations and closes the last interval of observations.double
Return the last observed value.void
Initialize the statistic.boolean
isActive()
Return whether the statistic is active (accepting observations) or not.double
register
(double timestamp, double value) Explicit;y override the double value method signature of WeightedTally to call the right method.
Process one observed double value.double
Process one observed Number-based value.double
Process one observed Calender-based value.protected double
registerValue
(Number timestamp, double value) Process one observed Number-based value.static String
Return a string representing a footer for a textual table with a monospaced font that can contain multiple statistics.static String
Return a string representing a header for a textual table with a monospaced font that can contain multiple statistics.Return a string representing a line with important statistics values for this statistic, for a textual table with a monospaced font that can contain multiple statistics.toString()
Methods inherited from class org.djutils.stats.summarizers.WeightedTally
getDescription, getMax, getMin, getN, getWeightedPopulationMean, getWeightedPopulationStDev, getWeightedPopulationVariance, getWeightedSampleMean, getWeightedSampleStDev, getWeightedSampleVariance, getWeightedSum
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.stats.summarizers.Statistic
formatFixed
-
Constructor Details
-
TimestampWeightedTally
constructs a new TimestampWeightedTally with a description.- Parameters:
description
- String; the description of this TimestampWeightedTally
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:Statistic
Initialize the statistic.- Specified by:
initialize
in interfaceStatistic
- Overrides:
initialize
in classWeightedTally
-
isActive
public boolean isActive()Return whether the statistic is active (accepting observations) or not.- Returns:
- boolean; whether the statistic is active (accepting observations) or not
-
endObservations
End the observations and closes the last interval of observations. After ending, no more observations will be accepted. Calling this method will create an extra observation, and corresponding events for the EventBased implementations of this interface will be called.- Parameters:
timestamp
- Number; the Number object representing the final timestamp
-
endObservations
End the observations and closes the last interval of observations. After ending, no more observations will be accepted. Calling this method will create an extra observation, and corresponding events for the EventBased implementations of this interface will be called.- Parameters:
timestamp
- Calendar; the Calendar object representing the final timestamp
-
getLastValue
public double getLastValue()Return the last observed value.- Returns:
- double; the last observed value
-
register
Process one observed Calender-based value. The time used will be the Calendar's time in milliseconds. Silently ignore when a value is registered, but tally is not active, i.e. when endObservations() has been called.- Parameters:
timestamp
- Calendar; the Calendar object representing the timestampvalue
- double; the value to process- Returns:
- double; the value
- Throws:
NullPointerException
- when timestamp is nullIllegalArgumentException
- when value is NaNIllegalArgumentException
- when given timestamp is before last timestamp
-
register
Process one observed Number-based value. Silently ignore when a value is registered, but tally is not active, i.e. when endObservations() has been called.- Parameters:
timestamp
- Number; the object representing the timestampvalue
- double; the value to process- Returns:
- double; the value
- Throws:
NullPointerException
- when timestamp is nullIllegalArgumentException
- when value is NaN or timestamp is NaNIllegalArgumentException
- when given timestamp is before last timestamp
-
register
public double register(double timestamp, double value) Explicit;y override the double value method signature of WeightedTally to call the right method.
Process one observed double value. Silently ignore when a value is registered, but tally is not active, i.e. when endObservations() has been called.- Overrides:
register
in classWeightedTally
- Parameters:
timestamp
- Number; the object representing the timestampvalue
- double; the value to process- Returns:
- double; the value
- Throws:
NullPointerException
- when timestamp is nullIllegalArgumentException
- when value is NaN or timestamp is NaNIllegalArgumentException
- when given timestamp is before last timestamp
-
registerValue
Process one observed Number-based value. Silently ignore when a value is registered, but tally is not active, i.e. when endObservations() has been called.- Parameters:
timestamp
- Number; the object representing the timestampvalue
- double; the value to process- Returns:
- double; the value
- Throws:
NullPointerException
- when timestamp is nullIllegalArgumentException
- when value is NaN or timestamp is NaNIllegalArgumentException
- when given timestamp is before last timestamp
-
reportHeader
Return a string representing a header for a textual table with a monospaced font that can contain multiple statistics.- Returns:
- String; header for the textual table.
-
reportLine
Description copied from interface:Statistic
Return a string representing a line with important statistics values for this statistic, for a textual table with a monospaced font that can contain multiple statistics.- Specified by:
reportLine
in interfaceStatistic
- Overrides:
reportLine
in classWeightedTally
- Returns:
- String; line with most important values of the statistic
-
toString
- Overrides:
toString
in classWeightedTally
-