empiricalC {mc2d} | R Documentation |
Density, distribution function and random generation for a continuous empirical distribution.
dempiricalC(x, min, max, values, prob=rep(1, length(values)), log=FALSE) pempiricalC(q, min, max, values, prob=rep(1, length(values)), lower.tail=TRUE, log.p=FALSE) qempiricalC(p, min, max, values, prob=rep(1, length(values)), lower.tail=TRUE, log.p=FALSE) rempiricalC(n, min, max, values, prob=rep(1, length(values)))
x, q |
Vector of quantiles. |
p |
Vector of probabilities. |
n |
Number of random values. If length(n) > 1, the length is taken to be the number required. |
min |
A finite minimal value. |
max |
A finite maximal value. |
values |
Vector of numerical values. |
prob |
Optionnal vector of count or probabilities. |
log, log.p |
logical; if TRUE, probabilities p are given as log(p). |
lower.tail |
logical; if TRUE (default), probabilities are P[X <= x], otherwise, P[X > x]. |
Given p_i, the distribution value for x_i with i the rank i = 0, 1, 2, ..., N+1, x_0 = min and x_(N+1) = max the density is:
f(x) = p_i + (p_(i+1) - p_i)/(x_(i+1) - x_i) for x_i<=x<x_(i+1)
The p values being normalized to give the distribution a unit area.
This function is not vectorized. It can not currently be use with varying parameters.
dempiricalC gives the density, pempiricalC gives the distribution function, qempiricalC gives the quantile function and rempiricalC generates random deviates.
Regis Pouillot
prob <- c(2, 3, 1, 6, 1) values <- 1:5 par(mfrow=c(1, 2)) curve(dempiricalC(x, min=0, max=6, values, prob), from=-1, to=7, n=1001) curve(pempiricalC(x, min=0, max=6, values, prob), from=-1, to=7, n=1001)