Class WeightedTally

java.lang.Object
org.djutils.stats.summarizers.WeightedTally
All Implemented Interfaces:
Serializable, Statistic, TallyStatistic
Direct Known Subclasses:
EventBasedWeightedTally, TimestampWeightedTally

public class WeightedTally extends Object implements TallyStatistic
The WeightedTally class defines a statistical tally. A WeightedTally is a time-weighted tally. The WeightedTally used to extend the Tally, but because the calculation method and method signatures are different, the WeightedTally has been made self-contained.

Copyright (c) 2002-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, Peter Knoppers
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Object
    The synchronization lock.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WeightedTally(String description)
    Construct a new WeightedTally with a description.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the description of the statistic.
    double
    Returns the maximum value of any given observation, or NaN when no observations were registered.
    double
    Returns the minimum value of any given observation, or NaN when no observations were registered.
    long
    Return the current number of observations.
    double
    Retrieve the current weighted mean of all observations since the initialization.
    double
    Retrieve the current weighted standard deviation of the observations.
    double
    Retrieve the current weighted variance of the observations.
    double
    Retrieve the current weighted sample mean of all observations since the initialization.
    double
    Retrieve the current weighted sample standard deviation of the observations.
    double
    Retrieve the current weighted sample variance of the observations.
    double
    Retrieve the current weighted sum of the values of the observations.
    void
    Initialize the statistic.
    double
    register(double weight, double value)
    Process one observed weighted 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.
     

    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
  • Field Details

    • semaphore

      protected Object semaphore
      The synchronization lock.
  • Constructor Details

    • WeightedTally

      public WeightedTally(String description)
      Construct a new WeightedTally with a description.
      Parameters:
      description - String; the description of this WeightedTally
  • Method Details

    • initialize

      public void initialize()
      Description copied from interface: Statistic
      Initialize the statistic.
      Specified by:
      initialize in interface Statistic
    • register

      public double register(double weight, double value)
      Process one observed weighted value.
      Parameters:
      weight - double; the weight of the value to process
      value - double; the value to process
      Returns:
      double; the value
    • getDescription

      public String getDescription()
      Description copied from interface: Statistic
      Returns the description of the statistic.
      Specified by:
      getDescription in interface Statistic
      Returns:
      String; the description of the statistic
    • getMax

      public double getMax()
      Description copied from interface: TallyStatistic
      Returns the maximum value of any given observation, or NaN when no observations were registered.
      Specified by:
      getMax in interface TallyStatistic
      Returns:
      double; the maximum value of any given observation
    • getMin

      public double getMin()
      Description copied from interface: TallyStatistic
      Returns the minimum value of any given observation, or NaN when no observations were registered.
      Specified by:
      getMin in interface TallyStatistic
      Returns:
      double; the minimum value of any given observation
    • getN

      public long getN()
      Description copied from interface: Statistic
      Return the current number of observations.
      Specified by:
      getN in interface Statistic
      Returns:
      long; the number of observations
    • getWeightedSampleMean

      public double getWeightedSampleMean()
      Retrieve the current weighted sample mean of all observations since the initialization.
      Returns:
      double; the current weighted sample mean
    • getWeightedPopulationMean

      public double getWeightedPopulationMean()
      Retrieve the current weighted mean of all observations since the initialization.
      Returns:
      double; the current weighted mean
    • getWeightedSampleStDev

      public double getWeightedSampleStDev()
      Retrieve the current weighted sample standard deviation of the observations.
      Returns:
      double; the current weighted sample standard deviation
    • getWeightedPopulationStDev

      public double getWeightedPopulationStDev()
      Retrieve the current weighted standard deviation of the observations.
      Returns:
      double; the current weighted standard deviation
    • getWeightedSampleVariance

      public double getWeightedSampleVariance()
      Retrieve the current weighted sample variance of the observations.
      Returns:
      double; the current weighted sample variance of the observations
    • getWeightedPopulationVariance

      public double getWeightedPopulationVariance()
      Retrieve the current weighted variance of the observations.
      Returns:
      double; the current weighted variance of the observations
    • getWeightedSum

      public double getWeightedSum()
      Retrieve the current weighted sum of the values of the observations.
      Returns:
      double; the current weighted sum of the values of the observations
    • reportHeader

      public static String 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

      public String 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 interface Statistic
      Returns:
      String; line with most important values of the statistic
    • reportFooter

      public static String reportFooter()
      Return a string representing a footer for a textual table with a monospaced font that can contain multiple statistics.
      Returns:
      String; footer for the textual table
    • toString

      public String toString()
      Overrides:
      toString in class Object