get_quantiles: Get quantiles for a given probability distribution

Description Usage Arguments Author(s) Examples

View source: R/get_quantiles.R

Description

These functions approximate quantiles for a probability density function or mass function given by a function f.

Usage

1
2
get_quantiles(f, p, continuous = NULL, precision = 0.01, n_steps = 1000,
  maxit = 1000, ...)

Arguments

f

A function returning the probability density function (for get_quantiles_pdf) or the probability mass function (for get_quantiles_pmf.

p

A vector of probabilities.

continuous

A logical indicating if the distribution computed by f is continuous (i.e., a probability density function) or discrete (i.e. a probability mass function). Automatically detected if the function provided is an instance of fpaircase.

precision

The size of the step used to discretise the continuous distribution. Defaults to 0.01.

n_steps

The number steps used to discretise the continuous distribution. Defaults to 1000. Note that if n_steps intervals are not enough to attain the largest value in p, batches of n_steps are iteratively added.

maxit

The maximum number of batches of n_steps considered. Defaults to 1000. Avoids infinite looping when p is close to 1.

...

Further arguments passed to the function f

Author(s)

Anne Cori (a.cori@imperial.ac.uk) and Thibaut Jombart.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## reference: exponential of rate 1
qexp(c(.4, .5, .95))

## approximation
get_quantiles(f = dexp, c(.4,.5,.95), TRUE)

## better precision
get_quantiles(f = dexp, c(.4,.5,.95), precision = 0.001, TRUE)


## example with fpaircase
f <- fpaircase("spatial", sd_spatial=10)
plot(f)
plot(f, xlim = c(0, 100))
plot(f, xlim = c(0, 100), pi = 0.4)

q <- get_quantiles(f, c(.9, .95, .99))
q
abline(v = q)

reconhub/vimes documentation built on May 27, 2019, 4:03 a.m.