auc {qslice}R Documentation

Area Under the Curve (histogram)

Description

Calculate the histogram approximation to the area under the curve after restricting the curve to fit within the unit square. Specifically, the highest histogram bar reaches 1 and the support is the unit interval. See Heiner et al. (2024+).

Usage

auc(u = NULL, x = NULL, y = NULL, nbins = 30)

Arguments

u

Numeric vector of samples supported on unit interval with which to create a histogram (use u = NULL if x and y are supplied).

x

Numeric vector of histogram locations. (Not used if u is supplied).

y

Numeric vector of histogram heights OR function evaluating the curve for a given value of u supported on (0,1). (Not used if u is supplied).

nbins

Number of histogram bins to use (defaults to 30).

Details

Accepts either samples u or a function y representing a (possibly unnormalized) probability density supported on the unit interval.

Value

The (approximate) area under the curve as a numeric value of length one.

References

Heiner, M. J., Johnson, S. B., Christensen, J. R., and Dahl, D. B. (2024+), "Quantile Slice Sampling," arXiv preprint arXiv:###.

Examples

u_samples <- rbeta(10e3, 2, 2)
auc(u = u_samples)
auc(u = u_samples, nbins = 50)
auc(y = function(x) {dbeta(x, 2, 2)}, nbins = 30)
auc(y = function(x) {dbeta(x, 2, 2)}, nbins = 300)
xx <- seq(0.001, 0.999, length = 1000)
auc(x = xx, y = function(x) {dbeta(x, 2, 2)})
auc(x = xx, y = dbeta(xx, 2, 2))

[Package qslice version 0.3.1 Index]