| dempirical | R Documentation |
Density (point mass), distribution, quantile function, as well as a random generation for the Empirical distribution.
dempirical(x, y, log = FALSE, na.rm = TRUE, method = NULL, ...)
pempirical(q, y, lower.tail = TRUE, log.p = FALSE, na.rm = TRUE)
qempirical(
p,
y,
lower.tail = TRUE,
log.p = FALSE,
na.rm = TRUE,
type = 1L,
...
)
rempirical(n, y, na.rm = TRUE)
x |
Vector of finite quantiles. |
y |
Vector of observations of the empirical distribution with two or more non-missing finite values. |
log, log.p |
logical. Indicates whether probabilities p are given as log(p)
(both default to |
na.rm |
logical indicating whether missing values ( |
method |
|
... |
Allows to forward arguments to |
q |
vector of quantiles. |
lower.tail |
logical indicating whether probabilities are |
p |
numeric vector of probabilities ( |
type |
integer, forwarded to |
n |
number of observations. If |
All functions follow the usual conventions of d/p/q/r functions in base R. In
particular, all four functions for the Empirical distribution call
the corresponding *empirical functions.
Other Empirical distribution:
Empirical(),
cdf.Empirical(),
pdf.Empirical(),
quantile.Empirical(),
random.Empirical(),
support.Empirical()
## Drawing two random empirical sample Y from the LogNormal distribution
## rounded to closest 0.5 (discrete)
set.seed(6020)
Y <- rlnorm(500L, meanlog = 1.5, sdlog = log(1.5))
Y <- round(Y * 2) / 2
bk <- seq(-0.25, 18.25, by = 1L)
hist(Y, freq = FALSE, breaks = bk, main = "Sample histogram")
x <- seq(0, 15, by = 0.5) # Quantiles
density <- dempirical(x, Y)
plot(density ~ x, type = "h", main = "Empirical density")
probability <- pempirical(x, Y)
plot(probability ~ x, type = "s", main = "Empirical distribution")
probs <- seq(0.01, 0.99, by = 0.01)
quantiles <- qempirical(probs, Y)
plot(probs ~ quantiles, type = "S", col = 2,
main = "Empirical quantile function")
## Drawing random numbers (sampling with replacement)
set.seed(6020)
r <- rempirical(500L, Y)
hist(Y, freq = FALSE, breaks = bk, main = "Sample histogram")
hist(r, freq = FALSE, breaks = bk, main = "Random sample histogram")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.