quantiles: Histogram Approximate Quantiles.

Description Usage Arguments Details Author(s) See Also Examples

Description

Approximate the quantiles of the underlying distribution for which only a histogram is available.

Usage

1
2
3

Arguments

x

A histogram object (created by hist).

probs

Numeric vector of probabilities with values in [0,1].

...

Any other arguments to pass to wtd.quantile.

Details

Many data analysis pipelines write out histogram protocol buffers with thousands of buckets so as to be applicable in a wide range of contexts. This function provides a way to transform the histogram into approximations of the quantile, median, mean, etc of the underlying distribution. Count(x) returns the number of observations in the histogram.

Author(s)

Murray Stokely mstokely@google.com

See Also

histogramtools-package and hist.

Examples

1
2
3
4
5
x <- hist(c(1,2,3), breaks=c(0,1,2,3,4,5,6,7,8,9), plot=FALSE)
Count(x)
ApproxMean(x)
ApproxQuantile(x, .5)
ApproxQuantile(x, c(.05, .95))

Example output

[1] 3
[1] 1.5
50% 
1.5 
Warning message:
In ApproxQuantile(x, 0.5) :
  Quantiles computed for histograms with fewer than 100 buckets may be inaccurate. Consider using histograms with more granular buckets.
 5% 95% 
0.6 5.1 
Warning message:
In ApproxQuantile(x, c(0.05, 0.95)) :
  Quantiles computed for histograms with fewer than 100 buckets may be inaccurate. Consider using histograms with more granular buckets.

HistogramTools documentation built on May 2, 2019, 6:15 p.m.