dpqr: d/p/q/r-family for a custom distribution

Description Usage Arguments Value Author(s) See Also Examples

View source: R/dpqr.R

Description

Produces the family of d/p/q/r functions associated with a custom one-dimensional distribution function; similarly to the standard families dnorm/pnorm/qnorm/rnorm, dunif/punif/...

Usage

1
dpqr(fun, min, max)

Arguments

fun

distribution function of a single variable; does not have to be normalized

min, max

domain of distribution function; outside this domain fun will be considered equal to 0. In practice, this should be the most restrictive domain containing (almost) all the mass of fun.

Value

Returns a list of items:

d(x)

Probability distribution function (PDF), i.e. a normalised version of fun, limited to the domain [xmin,xmax].

p(x)

Cumulative distributiont function, defined as the integrated PDF up to x.

q(p)

Quantile function, returning the position x, at which the cumulative probability equals p.

r(n)

A vector of n random numbers drawn from the PDF.

Author(s)

Danail Obreschkow

See Also

rng, contourlevel

Examples

1
2
3
4
5
f = function(x) sin(x)
rsin = dpqr(f,0,pi)$r
x = rsin(1e3)
hist(x,freq=FALSE)
curve(sin(x)/2,0,pi,add=TRUE)

physx documentation built on Feb. 3, 2022, 5:08 p.m.

Related to dpqr in physx...