Package org.xbib.metrics.common
Class WeightedSnapshot
- java.lang.Object
-
- org.xbib.metrics.common.WeightedSnapshot
-
- All Implemented Interfaces:
org.xbib.metrics.api.Snapshot
public class WeightedSnapshot extends java.lang.Object implements org.xbib.metrics.api.SnapshotA statistical snapshot of aWeightedSnapshot.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWeightedSnapshot.WeightedSampleA single sample item with value and its weights forWeightedSnapshot.
-
Constructor Summary
Constructors Constructor Description WeightedSnapshot(java.util.Collection<WeightedSnapshot.WeightedSample> values)Create a newSnapshotwith the given values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddump(java.io.OutputStream output)Writes the values of the snapshot to the given stream.doubleget75thPercentile()Returns the value at the 75th percentile in the distribution.doubleget95thPercentile()Returns the value at the 95th percentile in the distribution.doubleget98thPercentile()Returns the value at the 98th percentile in the distribution.doubleget999thPercentile()Returns the value at the 99.9th percentile in the distribution.doubleget99thPercentile()Returns the value at the 99th percentile in the distribution.longgetMax()Returns the highest value in the snapshot.doublegetMean()Returns the weighted arithmetic mean of the values in the snapshot.doublegetMedian()Returns the median value in the distribution.longgetMin()Returns the lowest value in the snapshot.doublegetStdDev()Returns the weighted standard deviation of the values in the snapshot.doublegetValue(double quantile)Returns the value at the given quantile.long[]getValues()Returns the entire set of values in the snapshot.intsize()Returns the number of values in the snapshot.
-
-
-
Constructor Detail
-
WeightedSnapshot
public WeightedSnapshot(java.util.Collection<WeightedSnapshot.WeightedSample> values)
Create a newSnapshotwith the given values.- Parameters:
values- an unordered set of values in the reservoir
-
-
Method Detail
-
getMedian
public double getMedian()
Returns the median value in the distribution.- Specified by:
getMedianin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the median value
-
get75thPercentile
public double get75thPercentile()
Returns the value at the 75th percentile in the distribution.- Specified by:
get75thPercentilein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the value at the 75th percentile
-
get95thPercentile
public double get95thPercentile()
Returns the value at the 95th percentile in the distribution.- Specified by:
get95thPercentilein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the value at the 95th percentile
-
get98thPercentile
public double get98thPercentile()
Returns the value at the 98th percentile in the distribution.- Specified by:
get98thPercentilein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the value at the 98th percentile
-
get99thPercentile
public double get99thPercentile()
Returns the value at the 99th percentile in the distribution.- Specified by:
get99thPercentilein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the value at the 99th percentile
-
get999thPercentile
public double get999thPercentile()
Returns the value at the 99.9th percentile in the distribution.- Specified by:
get999thPercentilein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the value at the 99.9th percentile
-
getValue
public double getValue(double quantile)
Returns the value at the given quantile.- Specified by:
getValuein interfaceorg.xbib.metrics.api.Snapshot- Parameters:
quantile- a given quantile, in[0..1]- Returns:
- the value in the distribution at
quantile
-
size
public int size()
Returns the number of values in the snapshot.- Specified by:
sizein interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the number of values
-
getValues
public long[] getValues()
Returns the entire set of values in the snapshot.- Specified by:
getValuesin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the entire set of values
-
getMax
public long getMax()
Returns the highest value in the snapshot.- Specified by:
getMaxin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the highest value
-
getMin
public long getMin()
Returns the lowest value in the snapshot.- Specified by:
getMinin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the lowest value
-
getMean
public double getMean()
Returns the weighted arithmetic mean of the values in the snapshot.- Specified by:
getMeanin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the weighted arithmetic mean
-
getStdDev
public double getStdDev()
Returns the weighted standard deviation of the values in the snapshot.- Specified by:
getStdDevin interfaceorg.xbib.metrics.api.Snapshot- Returns:
- the weighted standard deviation value
-
dump
public void dump(java.io.OutputStream output)
Writes the values of the snapshot to the given stream.- Specified by:
dumpin interfaceorg.xbib.metrics.api.Snapshot- Parameters:
output- an output stream
-
-