| empiricalC | R Documentation |
Density, distribution function, quantile function and random generation for a continuous empirical distribution.
dempiricalC(x, min, max, values, prob = NULL, log = FALSE)
pempiricalC(q, min, max, values, prob = NULL, lower.tail = TRUE, log.p = FALSE)
qempiricalC(p, min, max, values, prob = NULL, lower.tail = TRUE, log.p = FALSE)
rempiricalC(n, min, max, values, prob = NULL)
x, q |
vector of quantiles. |
min |
a finite minimal value. |
max |
a finite maximal value. |
values |
vector of numerical values. |
prob |
optional vector of counts 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]’. |
p |
vector of probabilities. |
n |
number of random values. If ‘length(n) > 1’, the length is taken to be the number required. |
Given p_{i}, the distribution value for x_{i} with ‘i’
the rank i = 0, 1, 2, \ldots, N+1, x_{0}=min and
x_{N+1}=max, the density is:
f(x)=p_{i}+\frac{(p_{i+1}-p_{i})(x-x_{i})}{x_{i+1}-x_{i}}
The ‘p’ values are normalized to give the distribution a unit area.
‘min’ and/or ‘max’ and/or ‘values’ and/or ‘prob’ may vary: in that case, ‘min’ and/or ‘max’ should be vector(s). ‘values’ and/or ‘prob’ should be matrices, the first row being used for the first element of ‘x’, ‘q’, ‘p’ or the first random value, the second row for the second element, ... Recycling is permitted if the number of elements of ‘min’ or ‘max’ or the number of rows of ‘prob’ and ‘values’ are equal or equal to one.
‘dempiricalC’ gives the density, ‘pempiricalC’ gives the distribution function, ‘qempiricalC’ gives the quantile function and ‘rempiricalC’ generates random deviates.
empiricalD
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)
## Varying values
(values <- matrix(1:10, ncol=5))
dempiricalC(c(1, 1), values, min=0, max=11)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.