| quantile.Empirical | R Documentation |
Please see the documentation of Empirical() for some properties
of the Empirical distribution.
## S3 method for class 'Empirical'
quantile(x, probs, drop = TRUE, elementwise = NULL, type = 1L, ...)
x |
an object of class |
probs |
A vector of probabilities. |
drop |
logical. Should the result be simplified to a vector if possible? |
elementwise |
logical. Should each distribution in |
type |
integer, forwarded to |
... |
arguments to be passed to |
In case of a single distribution object, either a numeric
vector of length probs (if drop = TRUE, default) or a matrix with
length(probs) columns (if drop = FALSE). In case of a vectorized
distribution object, a matrix with length(probs) columns containing all
possible combinations.
Other Empirical distribution:
Empirical(),
cdf.Empirical(),
dempirical(),
pdf.Empirical(),
random.Empirical(),
support.Empirical()
set.seed(28)
X <- Empirical(rnorm(50))
X
mean(X)
variance(X)
skewness(X)
kurtosis(X)
random(X, 10)
pdf(X, 2)
log_pdf(X, 2)
cdf(X, 4)
quantile(X, 0.7)
### example: allowed types/classes of input arguments
## Single vector (will be coerced to numeric)
Y1 <- rnorm(3, mean = -10)
d1 <- Empirical(Y1)
d1
mean(d1)
## Unnamed list of vectors
Y2 <- list(as.character(rnorm(3, mean = -10)),
runif(6),
rpois(4, lambda = 15))
d2 <- Empirical(Y2)
d2
mean(d2)
## Named list of vectors
Y3 <- list("Normal" = as.character(rnorm(3, mean = -10)),
"Uniform" = runif(6),
"Poisson" = rpois(4, lambda = 15))
d3 <- Empirical(Y3)
d3
mean(d3)
## Matrix
Y4 <- matrix(rnorm(20), ncol = 5,
dimnames = list(paste0("D_", 1:4), paste0("obs_", 1:5)))
d4 <- Empirical(Y4)
d4
## Data frame
d5 <- Empirical(as.data.frame(Y4))
d5
identical(d4, d5)
mean(d5)
variance(d5)
skewness(d5)
kurtosis(d5)
pdf(d5, c(-0.5, 0, 0.5, 1)) # Defaults to elementwise = TRUE
pdf(d5, c(-0.5, 0, 0.5, 1), elementwise = FALSE)
cdf(d5, c(-0.5, 0, 0.5, 1)) # Defaults to elementwise = TRUE
cdf(d5, c(-0.5, 0, 0.5, 1), elementwise = FALSE)
quantile(d5, c(0.2, 0.4, 0.6, 0.8)) # Defaults to elementwise = TRUE
quantile(d5, c(0.2, 0.4, 0.6, 0.8), elementwise = FALSE)
## The quantile function is the inverse of the distribution
## function (cdf) if x in Y
set.seed(6020)
Y <- round(rlnorm(20, log(3), log(2)), 1)
d <- Empirical(Y)
cdf(d, 4.0)
quantile(d, cdf(d, 4.0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.