Package org.djutils.stats.summarizers
Class WeightedTally
java.lang.Object
org.djutils.stats.summarizers.WeightedTally
- All Implemented Interfaces:
Statistic,TallyStatistic
- Direct Known Subclasses:
EventBasedWeightedTally,TimestampWeightedTally
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-2025 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
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionWeightedTally(String description) Construct a new WeightedTally with a description. -
Method Summary
Modifier and TypeMethodDescriptionReturns the description of the statistic.doublegetMax()Returns the maximum value of any given observation, or NaN when no observations were registered.doublegetMin()Returns the minimum value of any given observation, or NaN when no observations were registered.longgetN()Return the current number of observations.doubleRetrieve the current weighted mean of all observations since the initialization.doubleRetrieve the current weighted standard deviation of the observations.doubleRetrieve the current weighted variance of the observations.doubleRetrieve the current weighted sample mean of all observations since the initialization.doubleRetrieve the current weighted sample standard deviation of the observations.doubleRetrieve the current weighted sample variance of the observations.doubleRetrieve the current weighted sum of the values of the observations.voidInitialize the statistic.doubleregister(double weight, double value) Process one observed weighted value.static StringReturn a string representing a footer for a textual table with a monospaced font that can contain multiple statistics.static StringReturn 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.voidsetDescription(String description) Set a new description of the statistic.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.stats.summarizers.Statistic
formatFixed
-
Field Details
-
semaphore
The synchronization lock.
-
-
Constructor Details
-
WeightedTally
Construct a new WeightedTally with a description.- Parameters:
description- the description of this WeightedTally
-
-
Method Details
-
initialize
public void initialize()Description copied from interface:StatisticInitialize the statistic.- Specified by:
initializein interfaceStatistic
-
setDescription
Description copied from interface:StatisticSet a new description of the statistic.- Specified by:
setDescriptionin interfaceStatistic- Parameters:
description- the new description of the statistic
-
register
public double register(double weight, double value) Process one observed weighted value.- Parameters:
weight- the weight of the value to processvalue- the value to process- Returns:
- the value
-
getDescription
Description copied from interface:StatisticReturns the description of the statistic.- Specified by:
getDescriptionin interfaceStatistic- Returns:
- the description of the statistic
-
getMax
public double getMax()Description copied from interface:TallyStatisticReturns the maximum value of any given observation, or NaN when no observations were registered.- Specified by:
getMaxin interfaceTallyStatistic- Returns:
- the maximum value of any given observation
-
getMin
public double getMin()Description copied from interface:TallyStatisticReturns the minimum value of any given observation, or NaN when no observations were registered.- Specified by:
getMinin interfaceTallyStatistic- Returns:
- the minimum value of any given observation
-
getN
public long getN()Description copied from interface:StatisticReturn the current number of observations. -
getWeightedSampleMean
public double getWeightedSampleMean()Retrieve the current weighted sample mean of all observations since the initialization.- Returns:
- the current weighted sample mean
-
getWeightedPopulationMean
public double getWeightedPopulationMean()Retrieve the current weighted mean of all observations since the initialization.- Returns:
- the current weighted mean
-
getWeightedSampleStDev
public double getWeightedSampleStDev()Retrieve the current weighted sample standard deviation of the observations.- Returns:
- the current weighted sample standard deviation
-
getWeightedPopulationStDev
public double getWeightedPopulationStDev()Retrieve the current weighted standard deviation of the observations.- Returns:
- the current weighted standard deviation
-
getWeightedSampleVariance
public double getWeightedSampleVariance()Retrieve the current weighted sample variance of the observations.- Returns:
- the current weighted sample variance of the observations
-
getWeightedPopulationVariance
public double getWeightedPopulationVariance()Retrieve the current weighted variance of the observations.- Returns:
- the current weighted variance of the observations
-
getWeightedSum
public double getWeightedSum()Retrieve the current weighted sum of the values of the observations.- Returns:
- the current weighted sum of the values of the observations
-
reportHeader
Return a string representing a header for a textual table with a monospaced font that can contain multiple statistics.- Returns:
- header for the textual table.
-
reportLine
Description copied from interface:StatisticReturn 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:
reportLinein interfaceStatistic- Returns:
- line with most important values of the statistic
-
toString
-