Class FixedBinsAccumulator
- java.lang.Object
-
- org.djutils.stats.summarizers.quantileaccumulator.FixedBinsAccumulator
-
- All Implemented Interfaces:
QuantileAccumulator
public class FixedBinsAccumulator extends Object implements QuantileAccumulator
FixedBinsAccumulator.java.
This accumulator is created with a caller prescribes set of bins. All bins have the same width.
Copyright (c) 2021-2021 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.- Author:
- Alexander Verbraeck, Peter Knoppers
-
-
Constructor Summary
Constructors Constructor Description FixedBinsAccumulator(double minimumBinCenter, double binWidth, int binCount)
Construct a new FullStorageAccumulator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getAboveCount()
Retrieve the number of ingested values that were above the range of this FixedBinsAccumulator.long
getBelowCount()
Retrieve the number of ingested values that were below the range of this FixedBinsAccumulator.double
getBinCenter(int bin)
Return the center of a particular bin.int
getBinCount()
Retrieve the bin count.double
getBinWidth()
Retrieve the bin width.double
getCumulativeProbability(Tally tally, double quantile)
Get, or estimate fraction of ingested values between -infinity up to and including a given quantile.long
getN()
Retrieve the total number of ingested values.double
getQuantile(Tally tally, double probability)
Compute (or approximate) the value that corresponds to the given fraction (percentile).double
ingest(double value)
Ingest one value with weight 1.void
initialize()
Reset (clear all accumulated information).String
toString()
-
-
-
Constructor Detail
-
FixedBinsAccumulator
public FixedBinsAccumulator(double minimumBinCenter, double binWidth, int binCount)
Construct a new FullStorageAccumulator.- Parameters:
minimumBinCenter
- double; center value of bin for minimum value of range (minimum value in range isminimumBinCenter - binWidth / 2
, maximum value in range isminimumBinCenter + binWidth * (binCount - 0.5)
)binWidth
- double; width of each binbinCount
- int; number of bins
-
-
Method Detail
-
getBinWidth
public double getBinWidth()
Retrieve the bin width.- Returns:
- double; the bin width
-
getBinCount
public int getBinCount()
Retrieve the bin count.- Returns:
- int; the bin count
-
getN
public long getN()
Retrieve the total number of ingested values.- Returns:
- long; the total number of ingested values
-
getBelowCount
public long getBelowCount()
Retrieve the number of ingested values that were below the range of this FixedBinsAccumulator.- Returns:
- long; the number of ingested values that were below the range of this FixedBinsAccumulator
-
getAboveCount
public long getAboveCount()
Retrieve the number of ingested values that were above the range of this FixedBinsAccumulator.- Returns:
- long; the number of ingested values that were above the range of this FixedBinsAccumulator
-
getBinCenter
public double getBinCenter(int bin)
Return the center of a particular bin.- Parameters:
bin
- int the bin number- Returns:
- double; the center of requested bin
-
ingest
public double ingest(double value)
Ingest one value with weight 1. Should be called only from the Tally object and AFTER processing the value in the tally.- Specified by:
ingest
in interfaceQuantileAccumulator
- Parameters:
value
- double; the value- Returns:
- double; the ingested value
-
getQuantile
public double getQuantile(Tally tally, double probability)
Compute (or approximate) the value that corresponds to the given fraction (percentile).- Specified by:
getQuantile
in interfaceQuantileAccumulator
- Parameters:
tally
- Tally; the tally object that accumulates mean, minimum, maximum, count, etc.probability
- double; value between 0.0 and 1.0 (both inclusive)- Returns:
- double; the computed or approximated quantile value
-
getCumulativeProbability
public double getCumulativeProbability(Tally tally, double quantile) throws IllegalArgumentException
Get, or estimate fraction of ingested values between -infinity up to and including a given quantile.- Specified by:
getCumulativeProbability
in interfaceQuantileAccumulator
- Parameters:
tally
- Tally; the tally object that accumulates mean, minimum, maximum, count, etc.quantile
- double; the given quantile- Returns:
- double; the estimated or observed fraction of ingested values between -infinity up to and including the given quantile. When this QuantileAccumulator has ingested zero values; this method shall return NaN.
- Throws:
IllegalArgumentException
- when quantile is NaN
-
initialize
public void initialize()
Reset (clear all accumulated information).- Specified by:
initialize
in interfaceQuantileAccumulator
-
-