Class TimestampWeightedTally

java.lang.Object
org.djutils.stats.summarizers.TimestampWeightedTally
All Implemented Interfaces:
Serializable, BasicTallyInterface, TimestampTallyInterface, WeightedTallyInterface

public class TimestampWeightedTally
extends Object
implements TimestampTallyInterface
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-2020 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:
Serialized Form
  • Constructor Details

    • TimestampWeightedTally

      public TimestampWeightedTally​(String description)
      constructs a new TimestampWeightedTally with a description.
      Parameters:
      description - String; the description of this TimestampWeightedTally
  • Method Details

    • initialize

      public void initialize()
      initializes the Tally. This methods sets the max, min, n, sum and variance values to their initial values.
      Specified by:
      initialize in interface BasicTallyInterface
    • isActive

      public final boolean isActive()
      Return whether the statistic is active (accepting observations) or not.
      Specified by:
      isActive in interface TimestampTallyInterface
      Returns:
      boolean; whether the statistic is active (accepting observations) or not
    • endObservations

      public final void endObservations​(Number timestamp)
      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.
      Specified by:
      endObservations in interface TimestampTallyInterface
      Parameters:
      timestamp - Number; the Number object representing the final timestamp
    • endObservations

      public void endObservations​(Calendar timestamp)
      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.
      Specified by:
      endObservations in interface TimestampTallyInterface
      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
    • ingest

      public double ingest​(Calendar timestamp, double value)
      Process one observed value.
      Parameters:
      timestamp - Calendar; the Calendar object representing the timestamp
      value - double; the value to process
      Returns:
      double; the value
    • ingest

      public double ingest​(Number timestamp, double value)
      Process one observed value.
      Parameters:
      timestamp - Number; the object representing the timestamp
      value - double; the value to process
      Returns:
      double; the value
    • getDescription

      public final String getDescription()
      returns the description of this tally.
      Specified by:
      getDescription in interface BasicTallyInterface
      Returns:
      Sting description
    • getN

      public final long getN()
      Returns the number of observations.
      Specified by:
      getN in interface BasicTallyInterface
      Returns:
      long n
    • getMax

      public final double getMax()
      Returns the max.
      Specified by:
      getMax in interface BasicTallyInterface
      Returns:
      double
    • getMin

      public final double getMin()
      Returns the min.
      Specified by:
      getMin in interface BasicTallyInterface
      Returns:
      double
    • getWeightedSampleMean

      public final double getWeightedSampleMean()
      Retrieve the current weighted sample mean of all observations since the initialization.
      Specified by:
      getWeightedSampleMean in interface WeightedTallyInterface
      Returns:
      double; the current weighted sample mean
    • getWeightedSampleStDev

      public final double getWeightedSampleStDev()
      Retrieve the current weighted sample standard deviation of the observations.
      Specified by:
      getWeightedSampleStDev in interface WeightedTallyInterface
      Returns:
      double; the current weighted sample standard deviation
    • getWeightedPopulationStDev

      public final double getWeightedPopulationStDev()
      Retrieve the current weighted standard deviation of the observations.
      Specified by:
      getWeightedPopulationStDev in interface WeightedTallyInterface
      Returns:
      double; the current weighted standard deviation
    • getWeightedSampleVariance

      public final double getWeightedSampleVariance()
      Retrieve the current weighted sample variance of the observations.
      Specified by:
      getWeightedSampleVariance in interface WeightedTallyInterface
      Returns:
      double; the current weighted sample variance of the observations
    • getWeightedPopulationVariance

      public final double getWeightedPopulationVariance()
      Retrieve the current weighted variance of the observations.
      Specified by:
      getWeightedPopulationVariance in interface WeightedTallyInterface
      Returns:
      double; the current weighted variance of the observations
    • getWeightedSum

      public final double getWeightedSum()
      Retrieve the current weighted sum of the values of the observations.
      Specified by:
      getWeightedSum in interface WeightedTallyInterface
      Returns:
      double; the current weighted sum of the values of the observations
    • toString

      public String toString()
      Overrides:
      toString in class Object