% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_percentile.R
\name{dist_quantile}
\alias{dist_quantile}
\alias{dist_percentile}
\title{Quantile distribution}
\usage{
dist_quantile(x, quantile)

dist_percentile(x, percentile)
}
\arguments{
\item{x}{A list of values}

\item{quantile}{A list of quantile probabilities (between 0 and 1)}

\item{percentile}{A list of percentiles (between 0 and 100)}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}

The Quantile distribution is a non-parametric distribution defined by
a set of values at specified quantile probabilities. This distribution is
useful for representing empirical distributions or elicited expert
knowledge when only quantile information is available. The distribution
uses linear interpolation between quantiles and can be used to
approximate complex distributions that may not have simple parametric forms.
}
\details{
We recommend reading this documentation on \href{https://pkg.mitchelloharawild.com/distributional/reference/dist_quantile.html}{pkgdown} which renders math nicely.
\url{https://pkg.mitchelloharawild.com/distributional/reference/dist_quantile.html}

In the following, let \eqn{X} be a Quantile random variable defined by
values \eqn{x_1, x_2, \ldots, x_n} at quantile probabilities
\eqn{q_1, q_2, \ldots, q_n} where \eqn{0 \le q_i \le 1}.

\strong{Support}: \eqn{[\min(x_i), \max(x_i)]} if \eqn{\min(q_i) > 0} or
\eqn{\max(q_i) < 1}, otherwise support is approximated from the
specified quantiles.

\strong{Mean}: Approximated numerically using spline interpolation and
numerical integration:

\deqn{
    E(X) \approx \int_0^1 Q(u) du
  }{
    E(X) ≈ integral_0^1 Q(u) du
  }

  where \eqn{Q(u)} is a spline function interpolating the quantile values.

\strong{Variance}: Approximated numerically.

\strong{Probability density function (p.d.f)}: Approximated numerically using
kernel density estimation from generated samples.

\strong{Cumulative distribution function (c.d.f)}: Defined by linear
interpolation:

\deqn{
    F(t) = \begin{cases}
      q_1 & \text{if } t < x_1 \\
      q_i + \frac{(t - x_i)(q_{i+1} - q_i)}{x_{i+1} - x_i} & \text{if } x_i \le t < x_{i+1} \\
      q_n & \text{if } t \ge x_n
    \end{cases}
  }{
    F(t) = q_i + (t - x_i)(q_{i+1} - q_i) / (x_{i+1} - x_i) for x_i ≤ t < x_{i+1}
  }

  \strong{Quantile function}: Defined by linear interpolation:

\deqn{
    Q(u) = x_i + \frac{(u - q_i)(x_{i+1} - x_i)}{q_{i+1} - q_i}
  }{
    Q(u) = x_i + (u - q_i)(x_{i+1} - x_i) / (q_{i+1} - q_i)
  }

for \eqn{q_i \le u \le q_{i+1}}.
}
\examples{
dist <- dist_normal()
probs <- seq(0.01, 0.99, by = 0.01)
x <- vapply(probs, quantile, double(1L), x = dist)
dist_quantile(list(x), list(probs))
dist_percentile(list(x), list(probs * 100))

}
