distributional/ 0000755 0001762 0000144 00000000000 14560702732 013314 5 ustar ligges users distributional/NAMESPACE 0000644 0001762 0000144 00000036315 14560645377 014556 0 ustar ligges users # Generated by roxygen2: do not edit by hand
S3method("$",hilo)
S3method("[[",distribution)
S3method("dimnames<-",distribution)
S3method("names<-",hilo)
S3method(.DollarNames,hilo)
S3method(Math,dist_default)
S3method(Math,dist_lognormal)
S3method(Math,dist_na)
S3method(Math,dist_normal)
S3method(Math,dist_sample)
S3method(Math,dist_transformed)
S3method(Ops,dist_default)
S3method(Ops,dist_na)
S3method(Ops,dist_normal)
S3method(Ops,dist_sample)
S3method(Ops,dist_transformed)
S3method(cdf,dist_bernoulli)
S3method(cdf,dist_beta)
S3method(cdf,dist_binomial)
S3method(cdf,dist_burr)
S3method(cdf,dist_categorical)
S3method(cdf,dist_cauchy)
S3method(cdf,dist_chisq)
S3method(cdf,dist_default)
S3method(cdf,dist_degenerate)
S3method(cdf,dist_exponential)
S3method(cdf,dist_f)
S3method(cdf,dist_gamma)
S3method(cdf,dist_geometric)
S3method(cdf,dist_gumbel)
S3method(cdf,dist_hypergeometric)
S3method(cdf,dist_inflated)
S3method(cdf,dist_inverse_exponential)
S3method(cdf,dist_inverse_gamma)
S3method(cdf,dist_inverse_gaussian)
S3method(cdf,dist_logarithmic)
S3method(cdf,dist_logistic)
S3method(cdf,dist_lognormal)
S3method(cdf,dist_mixture)
S3method(cdf,dist_mvnorm)
S3method(cdf,dist_na)
S3method(cdf,dist_negbin)
S3method(cdf,dist_normal)
S3method(cdf,dist_pareto)
S3method(cdf,dist_percentile)
S3method(cdf,dist_poisson)
S3method(cdf,dist_poisson_inverse_gaussian)
S3method(cdf,dist_sample)
S3method(cdf,dist_student_t)
S3method(cdf,dist_studentized_range)
S3method(cdf,dist_transformed)
S3method(cdf,dist_truncated)
S3method(cdf,dist_uniform)
S3method(cdf,dist_weibull)
S3method(cdf,dist_wrap)
S3method(cdf,distribution)
S3method(covariance,default)
S3method(covariance,dist_bernoulli)
S3method(covariance,dist_beta)
S3method(covariance,dist_binomial)
S3method(covariance,dist_burr)
S3method(covariance,dist_categorical)
S3method(covariance,dist_cauchy)
S3method(covariance,dist_chisq)
S3method(covariance,dist_default)
S3method(covariance,dist_degenerate)
S3method(covariance,dist_exponential)
S3method(covariance,dist_f)
S3method(covariance,dist_gamma)
S3method(covariance,dist_geometric)
S3method(covariance,dist_gumbel)
S3method(covariance,dist_hypergeometric)
S3method(covariance,dist_inflated)
S3method(covariance,dist_inverse_exponential)
S3method(covariance,dist_inverse_gamma)
S3method(covariance,dist_inverse_gaussian)
S3method(covariance,dist_logarithmic)
S3method(covariance,dist_logistic)
S3method(covariance,dist_lognormal)
S3method(covariance,dist_mixture)
S3method(covariance,dist_multinomial)
S3method(covariance,dist_mvnorm)
S3method(covariance,dist_na)
S3method(covariance,dist_negbin)
S3method(covariance,dist_normal)
S3method(covariance,dist_pareto)
S3method(covariance,dist_poisson)
S3method(covariance,dist_poisson_inverse_gaussian)
S3method(covariance,dist_sample)
S3method(covariance,dist_student_t)
S3method(covariance,dist_transformed)
S3method(covariance,dist_uniform)
S3method(covariance,dist_weibull)
S3method(covariance,distribution)
S3method(covariance,numeric)
S3method(density,dist_bernoulli)
S3method(density,dist_beta)
S3method(density,dist_binomial)
S3method(density,dist_burr)
S3method(density,dist_categorical)
S3method(density,dist_cauchy)
S3method(density,dist_chisq)
S3method(density,dist_default)
S3method(density,dist_degenerate)
S3method(density,dist_exponential)
S3method(density,dist_f)
S3method(density,dist_gamma)
S3method(density,dist_geometric)
S3method(density,dist_gumbel)
S3method(density,dist_hypergeometric)
S3method(density,dist_inflated)
S3method(density,dist_inverse_exponential)
S3method(density,dist_inverse_gamma)
S3method(density,dist_inverse_gaussian)
S3method(density,dist_logarithmic)
S3method(density,dist_logistic)
S3method(density,dist_lognormal)
S3method(density,dist_mixture)
S3method(density,dist_multinomial)
S3method(density,dist_mvnorm)
S3method(density,dist_na)
S3method(density,dist_negbin)
S3method(density,dist_normal)
S3method(density,dist_pareto)
S3method(density,dist_poisson)
S3method(density,dist_poisson_inverse_gaussian)
S3method(density,dist_sample)
S3method(density,dist_student_t)
S3method(density,dist_transformed)
S3method(density,dist_truncated)
S3method(density,dist_uniform)
S3method(density,dist_weibull)
S3method(density,dist_wrap)
S3method(density,distribution)
S3method(dim,dist_default)
S3method(dim,dist_multinomial)
S3method(dim,dist_mvnorm)
S3method(dimnames,distribution)
S3method(family,dist_default)
S3method(family,distribution)
S3method(format,dist_bernoulli)
S3method(format,dist_beta)
S3method(format,dist_binomial)
S3method(format,dist_burr)
S3method(format,dist_categorical)
S3method(format,dist_cauchy)
S3method(format,dist_chisq)
S3method(format,dist_default)
S3method(format,dist_degenerate)
S3method(format,dist_exponential)
S3method(format,dist_f)
S3method(format,dist_gamma)
S3method(format,dist_geometric)
S3method(format,dist_gumbel)
S3method(format,dist_hypergeometric)
S3method(format,dist_inflated)
S3method(format,dist_inverse_exponential)
S3method(format,dist_inverse_gamma)
S3method(format,dist_inverse_gaussian)
S3method(format,dist_logarithmic)
S3method(format,dist_logistic)
S3method(format,dist_lognormal)
S3method(format,dist_mixture)
S3method(format,dist_multinomial)
S3method(format,dist_mvnorm)
S3method(format,dist_na)
S3method(format,dist_negbin)
S3method(format,dist_normal)
S3method(format,dist_pareto)
S3method(format,dist_percentile)
S3method(format,dist_poisson)
S3method(format,dist_poisson_inverse_gaussian)
S3method(format,dist_sample)
S3method(format,dist_student_t)
S3method(format,dist_studentized_range)
S3method(format,dist_transformed)
S3method(format,dist_truncated)
S3method(format,dist_uniform)
S3method(format,dist_weibull)
S3method(format,dist_wrap)
S3method(format,distribution)
S3method(format,hdr)
S3method(format,hilo)
S3method(format,support_region)
S3method(generate,dist_bernoulli)
S3method(generate,dist_beta)
S3method(generate,dist_binomial)
S3method(generate,dist_burr)
S3method(generate,dist_categorical)
S3method(generate,dist_cauchy)
S3method(generate,dist_chisq)
S3method(generate,dist_default)
S3method(generate,dist_degenerate)
S3method(generate,dist_exponential)
S3method(generate,dist_f)
S3method(generate,dist_gamma)
S3method(generate,dist_geometric)
S3method(generate,dist_gumbel)
S3method(generate,dist_hypergeometric)
S3method(generate,dist_inflated)
S3method(generate,dist_inverse_exponential)
S3method(generate,dist_inverse_gamma)
S3method(generate,dist_inverse_gaussian)
S3method(generate,dist_logarithmic)
S3method(generate,dist_logistic)
S3method(generate,dist_lognormal)
S3method(generate,dist_mixture)
S3method(generate,dist_multinomial)
S3method(generate,dist_mvnorm)
S3method(generate,dist_na)
S3method(generate,dist_negbin)
S3method(generate,dist_normal)
S3method(generate,dist_pareto)
S3method(generate,dist_percentile)
S3method(generate,dist_poisson)
S3method(generate,dist_poisson_inverse_gaussian)
S3method(generate,dist_sample)
S3method(generate,dist_student_t)
S3method(generate,dist_transformed)
S3method(generate,dist_uniform)
S3method(generate,dist_weibull)
S3method(generate,dist_wrap)
S3method(generate,distribution)
S3method(hdr,default)
S3method(hdr,dist_default)
S3method(hdr,distribution)
S3method(hilo,default)
S3method(hilo,dist_default)
S3method(hilo,distribution)
S3method(is.na,hilo)
S3method(kurtosis,dist_bernoulli)
S3method(kurtosis,dist_beta)
S3method(kurtosis,dist_binomial)
S3method(kurtosis,dist_categorical)
S3method(kurtosis,dist_cauchy)
S3method(kurtosis,dist_chisq)
S3method(kurtosis,dist_degenerate)
S3method(kurtosis,dist_exponential)
S3method(kurtosis,dist_f)
S3method(kurtosis,dist_gamma)
S3method(kurtosis,dist_geometric)
S3method(kurtosis,dist_gumbel)
S3method(kurtosis,dist_hypergeometric)
S3method(kurtosis,dist_logistic)
S3method(kurtosis,dist_lognormal)
S3method(kurtosis,dist_na)
S3method(kurtosis,dist_negbin)
S3method(kurtosis,dist_normal)
S3method(kurtosis,dist_poisson)
S3method(kurtosis,dist_uniform)
S3method(kurtosis,dist_weibull)
S3method(kurtosis,distribution)
S3method(likelihood,dist_default)
S3method(likelihood,distribution)
S3method(log_cdf,dist_default)
S3method(log_cdf,dist_lognormal)
S3method(log_cdf,dist_na)
S3method(log_cdf,dist_normal)
S3method(log_cdf,distribution)
S3method(log_density,dist_bernoulli)
S3method(log_density,dist_beta)
S3method(log_density,dist_binomial)
S3method(log_density,dist_burr)
S3method(log_density,dist_cauchy)
S3method(log_density,dist_chisq)
S3method(log_density,dist_default)
S3method(log_density,dist_exponential)
S3method(log_density,dist_f)
S3method(log_density,dist_gamma)
S3method(log_density,dist_geometric)
S3method(log_density,dist_gumbel)
S3method(log_density,dist_hypergeometric)
S3method(log_density,dist_inverse_exponential)
S3method(log_density,dist_inverse_gamma)
S3method(log_density,dist_inverse_gaussian)
S3method(log_density,dist_logarithmic)
S3method(log_density,dist_logistic)
S3method(log_density,dist_lognormal)
S3method(log_density,dist_multinomial)
S3method(log_density,dist_mvnorm)
S3method(log_density,dist_na)
S3method(log_density,dist_negbin)
S3method(log_density,dist_normal)
S3method(log_density,dist_pareto)
S3method(log_density,dist_poisson)
S3method(log_density,dist_poisson_inverse_gaussian)
S3method(log_density,dist_student_t)
S3method(log_density,dist_uniform)
S3method(log_density,dist_weibull)
S3method(log_density,dist_wrap)
S3method(log_density,distribution)
S3method(log_likelihood,dist_default)
S3method(log_likelihood,distribution)
S3method(log_quantile,dist_default)
S3method(log_quantile,dist_lognormal)
S3method(log_quantile,dist_na)
S3method(log_quantile,dist_normal)
S3method(log_quantile,distribution)
S3method(mean,dist_bernoulli)
S3method(mean,dist_beta)
S3method(mean,dist_binomial)
S3method(mean,dist_burr)
S3method(mean,dist_categorical)
S3method(mean,dist_cauchy)
S3method(mean,dist_chisq)
S3method(mean,dist_default)
S3method(mean,dist_degenerate)
S3method(mean,dist_exponential)
S3method(mean,dist_f)
S3method(mean,dist_gamma)
S3method(mean,dist_geometric)
S3method(mean,dist_gumbel)
S3method(mean,dist_hypergeometric)
S3method(mean,dist_inflated)
S3method(mean,dist_inverse_exponential)
S3method(mean,dist_inverse_gamma)
S3method(mean,dist_inverse_gaussian)
S3method(mean,dist_logarithmic)
S3method(mean,dist_logistic)
S3method(mean,dist_lognormal)
S3method(mean,dist_mixture)
S3method(mean,dist_multinomial)
S3method(mean,dist_mvnorm)
S3method(mean,dist_na)
S3method(mean,dist_negbin)
S3method(mean,dist_normal)
S3method(mean,dist_pareto)
S3method(mean,dist_poisson)
S3method(mean,dist_poisson_inverse_gaussian)
S3method(mean,dist_sample)
S3method(mean,dist_student_t)
S3method(mean,dist_transformed)
S3method(mean,dist_truncated)
S3method(mean,dist_uniform)
S3method(mean,dist_weibull)
S3method(mean,distribution)
S3method(median,dist_default)
S3method(median,dist_sample)
S3method(median,distribution)
S3method(parameters,dist_default)
S3method(parameters,dist_wrap)
S3method(parameters,distribution)
S3method(print,dist_default)
S3method(quantile,dist_bernoulli)
S3method(quantile,dist_beta)
S3method(quantile,dist_binomial)
S3method(quantile,dist_burr)
S3method(quantile,dist_categorical)
S3method(quantile,dist_cauchy)
S3method(quantile,dist_chisq)
S3method(quantile,dist_default)
S3method(quantile,dist_degenerate)
S3method(quantile,dist_exponential)
S3method(quantile,dist_f)
S3method(quantile,dist_gamma)
S3method(quantile,dist_geometric)
S3method(quantile,dist_gumbel)
S3method(quantile,dist_hypergeometric)
S3method(quantile,dist_inflated)
S3method(quantile,dist_inverse_exponential)
S3method(quantile,dist_inverse_gamma)
S3method(quantile,dist_inverse_gaussian)
S3method(quantile,dist_logarithmic)
S3method(quantile,dist_logistic)
S3method(quantile,dist_lognormal)
S3method(quantile,dist_mixture)
S3method(quantile,dist_mvnorm)
S3method(quantile,dist_na)
S3method(quantile,dist_negbin)
S3method(quantile,dist_normal)
S3method(quantile,dist_pareto)
S3method(quantile,dist_percentile)
S3method(quantile,dist_poisson)
S3method(quantile,dist_poisson_inverse_gaussian)
S3method(quantile,dist_sample)
S3method(quantile,dist_student_t)
S3method(quantile,dist_studentized_range)
S3method(quantile,dist_transformed)
S3method(quantile,dist_truncated)
S3method(quantile,dist_uniform)
S3method(quantile,dist_weibull)
S3method(quantile,dist_wrap)
S3method(quantile,distribution)
S3method(skewness,dist_bernoulli)
S3method(skewness,dist_beta)
S3method(skewness,dist_binomial)
S3method(skewness,dist_categorical)
S3method(skewness,dist_cauchy)
S3method(skewness,dist_chisq)
S3method(skewness,dist_degenerate)
S3method(skewness,dist_exponential)
S3method(skewness,dist_f)
S3method(skewness,dist_gamma)
S3method(skewness,dist_geometric)
S3method(skewness,dist_gumbel)
S3method(skewness,dist_hypergeometric)
S3method(skewness,dist_logistic)
S3method(skewness,dist_lognormal)
S3method(skewness,dist_na)
S3method(skewness,dist_negbin)
S3method(skewness,dist_normal)
S3method(skewness,dist_poisson)
S3method(skewness,dist_sample)
S3method(skewness,dist_uniform)
S3method(skewness,dist_weibull)
S3method(skewness,distribution)
S3method(sum,distribution)
S3method(support,dist_categorical)
S3method(support,dist_default)
S3method(support,distribution)
S3method(variance,default)
S3method(variance,dist_default)
S3method(variance,distribution)
S3method(variance,matrix)
S3method(variance,numeric)
S3method(vec_arith,distribution)
S3method(vec_arith,hilo)
S3method(vec_arith.distribution,default)
S3method(vec_arith.numeric,distribution)
S3method(vec_arith.numeric,hilo)
S3method(vec_cast,character.distribution)
S3method(vec_cast,character.hilo)
S3method(vec_cast,distribution.distribution)
S3method(vec_cast,distribution.double)
S3method(vec_cast,distribution.integer)
S3method(vec_math,distribution)
S3method(vec_math,hilo)
S3method(vec_ptype2,distribution.distribution)
S3method(vec_ptype2,distribution.double)
S3method(vec_ptype2,distribution.integer)
S3method(vec_ptype2,double.distribution)
S3method(vec_ptype2,hilo.hilo)
S3method(vec_ptype2,integer.distribution)
S3method(vec_ptype_abbr,distribution)
S3method(vec_ptype_abbr,support_region)
export(cdf)
export(covariance)
export(dist_bernoulli)
export(dist_beta)
export(dist_binomial)
export(dist_burr)
export(dist_categorical)
export(dist_cauchy)
export(dist_chisq)
export(dist_degenerate)
export(dist_exponential)
export(dist_f)
export(dist_gamma)
export(dist_geometric)
export(dist_gumbel)
export(dist_hypergeometric)
export(dist_inflated)
export(dist_inverse_exponential)
export(dist_inverse_gamma)
export(dist_inverse_gaussian)
export(dist_logarithmic)
export(dist_logistic)
export(dist_lognormal)
export(dist_missing)
export(dist_mixture)
export(dist_multinomial)
export(dist_multivariate_normal)
export(dist_negative_binomial)
export(dist_normal)
export(dist_pareto)
export(dist_percentile)
export(dist_poisson)
export(dist_poisson_inverse_gaussian)
export(dist_sample)
export(dist_student_t)
export(dist_studentized_range)
export(dist_transformed)
export(dist_truncated)
export(dist_uniform)
export(dist_weibull)
export(dist_wrap)
export(generate)
export(hdr)
export(hilo)
export(is_distribution)
export(is_hdr)
export(is_hilo)
export(kurtosis)
export(likelihood)
export(log_likelihood)
export(new_dist)
export(new_hdr)
export(new_hilo)
export(parameters)
export(skewness)
export(support)
export(variance)
import(rlang)
import(vctrs)
importFrom(generics,generate)
importFrom(lifecycle,deprecate_soft)
importFrom(lifecycle,deprecated)
importFrom(stats,density)
importFrom(stats,family)
importFrom(stats,median)
importFrom(stats,quantile)
importFrom(utils,.DollarNames)
distributional/README.md 0000644 0001762 0000144 00000013116 14475774237 014613 0 ustar ligges users
# distributional
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://github.com/mitchelloharawild/distributional/actions/workflows/R-CMD-check.yaml)
[](https://CRAN.R-project.org/package=distributional)

The distributional package allows distributions to be used in a
vectorised context. It provides methods which are minimal wrappers to
the standard d, p, q, and r distribution functions which are applied to
each distribution in the vector. Additional distributional statistics
can be computed, including the `mean()`, `median()`, `variance()`, and
intervals with `hilo()`.
The distributional nature of a model’s predictions is often understated,
with default output of prediction methods usually only producing point
predictions. Some R packages (such as
[forecast](https://CRAN.R-project.org/package=forecast)) further
emphasise uncertainty by producing point forecasts and intervals by
default, however the user’s ability to interact with them is limited.
This package vectorises distributions and provides methods for working
with them, making distributions compatible with prediction outputs of
modelling functions. These vectorised distributions can be illustrated
with [ggplot2](https://CRAN.R-project.org/package=ggplot2) using the
[ggdist](https://CRAN.R-project.org/package=ggdist) package, providing
further opportunity to visualise the uncertainty of predictions and
teach distributional theory.
## Installation
You can install the released version of distributional from
[CRAN](https://CRAN.R-project.org/package=distributional) with:
``` r
install.packages("distributional")
```
The development version can be installed from
[GitHub](https://github.com/mitchelloharawild/distributional) with:
``` r
# install.packages("remotes")
remotes::install_github("mitchelloharawild/distributional")
```
## Examples
Distributions are created using `dist_*()` functions. A list of included
distribution shapes can be found here:
``` r
library(distributional)
my_dist <- c(dist_normal(mu = 0, sigma = 1), dist_student_t(df = 10))
my_dist
#>
#> [1] N(0, 1) t(10, 0, 1)
```
The standard four distribution functions in R are usable via these
generics:
``` r
density(my_dist, 0) # c(dnorm(0, mean = 0, sd = 1), dt(0, df = 10))
#> [1] 0.3989423 0.3891084
cdf(my_dist, 5) # c(pnorm(5, mean = 0, sd = 1), pt(5, df = 10))
#> [1] 0.9999997 0.9997313
quantile(my_dist, 0.1) # c(qnorm(0.1, mean = 0, sd = 1), qt(0.1, df = 10))
#> [1] -1.281552 -1.372184
generate(my_dist, 10) # list(rnorm(10, mean = 0, sd = 1), rt(10, df = 10))
#> [[1]]
#> [1] 1.262954285 -0.326233361 1.329799263 1.272429321 0.414641434
#> [6] -1.539950042 -0.928567035 -0.294720447 -0.005767173 2.404653389
#>
#> [[2]]
#> [1] 0.99165484 -1.36999677 -0.40943004 -0.85261144 -1.37728388 0.81020460
#> [7] -1.82965813 -0.06142032 -1.33933588 -0.28491414
```
You can also compute intervals using `hilo()`
``` r
hilo(my_dist, 0.95)
#>
#> [1] [-0.01190677, 0.01190677]0.95 [-0.01220773, 0.01220773]0.95
```
Additionally, some distributions may support other methods such as
mathematical operations and summary measures. If the methods aren’t
supported, a transformed distribution will be created.
``` r
my_dist
#>
#> [1] N(0, 1) t(10, 0, 1)
my_dist*3 + 2
#>
#> [1] N(2, 9) t(t(10, 0, 1))
mean(my_dist)
#> [1] 0 0
variance(my_dist)
#> [1] 1.00 1.25
```
You can also visualise the distribution(s) using the
[ggdist](https://mjskay.github.io/ggdist/) package.
``` r
library(ggdist)
library(ggplot2)
df <- data.frame(
name = c("Gamma(2,1)", "Normal(5,1)", "Mixture"),
dist = c(dist_gamma(2,1), dist_normal(5,1),
dist_mixture(dist_gamma(2,1), dist_normal(5, 1), weights = c(0.4, 0.6)))
)
ggplot(df, aes(y = factor(name, levels = rev(name)))) +
stat_dist_halfeye(aes(dist = dist)) +
labs(title = "Density function for a mixture of distributions", y = NULL, x = NULL)
```
## Related work
There are several packages which unify interfaces for distributions in
R:
- stats provides functions to work with possibly multiple
distributions (comparisons made below).
- [distributions3](https://cran.r-project.org/package=distributions3)
represents singular distributions using S3, with particularly nice
documentation. This package makes use of some code and documentation
from this package.
- [distr](https://cran.r-project.org/package=distr) represents
singular distributions using S4.
- [distr6](https://cran.r-project.org/package=distr6) represents
singular distributions using R6.
- Many more in the [CRAN task
view](https://cran.r-project.org/view=Distributions)
This package differs from the above libraries by storing the
distributions in a vectorised format. It does this using
[vctrs](https://vctrs.r-lib.org/), so it should play nicely with the
tidyverse (try putting distributions into a tibble\!).
distributional/man/ 0000755 0001762 0000144 00000000000 14560645400 014065 5 ustar ligges users distributional/man/dist_weibull.Rd 0000644 0001762 0000144 00000003222 14304314270 017033 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_weibull.R
\name{dist_weibull}
\alias{dist_weibull}
\title{The Weibull distribution}
\usage{
dist_weibull(shape, scale)
}
\arguments{
\item{shape, scale}{shape and scale parameters, the latter defaulting to 1.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Generalization of the gamma distribution. Often used in survival and
time-to-event analyses.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Weibull random variable with
success probability \code{p} = \eqn{p}.
\strong{Support}: \eqn{R^+} and zero.
\strong{Mean}: \eqn{\lambda \Gamma(1+1/k)}, where \eqn{\Gamma} is
the gamma function.
\strong{Variance}: \eqn{\lambda [ \Gamma (1 + \frac{2}{k} ) - (\Gamma(1+ \frac{1}{k}))^2 ]}
\strong{Probability density function (p.d.f)}:
\deqn{
f(x) = \frac{k}{\lambda}(\frac{x}{\lambda})^{k-1}e^{-(x/\lambda)^k}, x \ge 0
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{F(x) = 1 - e^{-(x/\lambda)^k}, x \ge 0}
\strong{Moment generating function (m.g.f)}:
\deqn{\sum_{n=0}^\infty \frac{t^n\lambda^n}{n!} \Gamma(1+n/k), k \ge 1}
}
\examples{
dist <- dist_weibull(shape = c(0.5, 1, 1.5, 5), scale = rep(1, 4))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Weibull]{stats::Weibull}
}
distributional/man/dist_inverse_gaussian.Rd 0000644 0001762 0000144 00000001737 14304314270 020746 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_inverse_gaussian.R
\name{dist_inverse_gaussian}
\alias{dist_inverse_gaussian}
\title{The Inverse Gaussian distribution}
\usage{
dist_inverse_gaussian(mean, shape)
}
\arguments{
\item{mean, shape}{parameters. Must be strictly positive. Infinite
values are supported.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_inverse_gaussian(mean = c(1,1,1,3,3), shape = c(0.2, 1, 3, 0.2, 1))
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:InverseGaussian]{actuar::InverseGaussian}
}
distributional/man/covariance.distribution.Rd 0000644 0001762 0000144 00000001237 14304314270 021201 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{covariance.distribution}
\alias{covariance.distribution}
\title{Covariance of a probability distribution}
\usage{
\method{covariance}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Returns the empirical covariance of the probability distribution. If the
method does not exist, the covariance of a random sample will be returned.
}
distributional/man/covariance.Rd 0000644 0001762 0000144 00000001143 14304316713 016463 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{covariance}
\alias{covariance}
\title{Covariance}
\usage{
covariance(x, ...)
}
\arguments{
\item{x}{An object.}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
A generic function for computing the covariance of an object.
}
\seealso{
\code{\link[=covariance.distribution]{covariance.distribution()}}, \code{\link[=variance]{variance()}}
}
distributional/man/mean.distribution.Rd 0000644 0001762 0000144 00000001173 14304314270 020006 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{mean.distribution}
\alias{mean.distribution}
\title{Mean of a probability distribution}
\usage{
\method{mean}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Returns the empirical mean of the probability distribution. If the method
does not exist, the mean of a random sample will be returned.
}
distributional/man/dist_inverse_gamma.Rd 0000644 0001762 0000144 00000001741 14304314270 020211 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_inverse_gamma.R
\name{dist_inverse_gamma}
\alias{dist_inverse_gamma}
\title{The Inverse Gamma distribution}
\usage{
dist_inverse_gamma(shape, rate = 1/scale, scale)
}
\arguments{
\item{shape, scale}{parameters. Must be strictly positive.}
\item{rate}{an alternative way to specify the scale.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_inverse_gamma(shape = c(1,2,3,3), rate = c(1,1,1,2))
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:InverseGamma]{actuar::InverseGamma}
}
distributional/man/dist_gamma.Rd 0000644 0001762 0000144 00000005062 14304314267 016464 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_gamma.R
\name{dist_gamma}
\alias{dist_gamma}
\title{The Gamma distribution}
\usage{
dist_gamma(shape, rate, scale = 1/rate)
}
\arguments{
\item{shape, scale}{shape and scale parameters. Must be positive,
\code{scale} strictly.}
\item{rate}{an alternative way to specify the scale.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Several important distributions are special cases of the Gamma
distribution. When the shape parameter is \code{1}, the Gamma is an
exponential distribution with parameter \eqn{1/\beta}. When the
\eqn{shape = n/2} and \eqn{rate = 1/2}, the Gamma is a equivalent to
a chi squared distribution with n degrees of freedom. Moreover, if
we have \eqn{X_1} is \eqn{Gamma(\alpha_1, \beta)} and
\eqn{X_2} is \eqn{Gamma(\alpha_2, \beta)}, a function of these two variables
of the form \eqn{\frac{X_1}{X_1 + X_2}} \eqn{Beta(\alpha_1, \alpha_2)}.
This last property frequently appears in another distributions, and it
has extensively been used in multivariate methods. More about the Gamma
distribution will be added soon.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Gamma random variable
with parameters
\code{shape} = \eqn{\alpha} and
\code{rate} = \eqn{\beta}.
\strong{Support}: \eqn{x \in (0, \infty)}
\strong{Mean}: \eqn{\frac{\alpha}{\beta}}
\strong{Variance}: \eqn{\frac{\alpha}{\beta^2}}
\strong{Probability density function (p.m.f)}:
\deqn{
f(x) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x}
}{
f(x) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x}
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{
f(x) = \frac{\Gamma(\alpha, \beta x)}{\Gamma{\alpha}}
}{
f(x) = \frac{\Gamma(\alpha, \beta x)}{\Gamma{\alpha}}
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta
}{
E(e^(tX)) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta
}
}
\examples{
dist <- dist_gamma(shape = c(1,2,3,5,9,7.5,0.5), rate = c(0.5,0.5,0.5,1,2,1,1))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:GammaDist]{stats::GammaDist}
}
distributional/man/dist_sample.Rd 0000644 0001762 0000144 00000001403 14304314270 016650 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_sample.R
\name{dist_sample}
\alias{dist_sample}
\title{Sampling distribution}
\usage{
dist_sample(x)
}
\arguments{
\item{x}{A list of sampled values.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
# Univariate numeric samples
dist <- dist_sample(x = list(rnorm(100), rnorm(100, 10)))
dist
mean(dist)
variance(dist)
skewness(dist)
generate(dist, 10)
density(dist, 1)
# Multivariate numeric samples
dist <- dist_sample(x = list(cbind(rnorm(100), rnorm(100, 10))))
dist
mean(dist)
variance(dist)
skewness(dist)
generate(dist, 10)
density(dist, 1)
}
distributional/man/dist_degenerate.Rd 0000644 0001762 0000144 00000002777 14304314267 017517 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_degenerate.R
\name{dist_degenerate}
\alias{dist_degenerate}
\title{The degenerate distribution}
\usage{
dist_degenerate(x)
}
\arguments{
\item{x}{The value of the distribution.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
The degenerate distribution takes a single value which is certain to be
observed. It takes a single parameter, which is the value that is observed
by the distribution.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a degenerate random variable with value
\code{x} = \eqn{k_0}.
\strong{Support}: \eqn{R}, the set of all real numbers
\strong{Mean}: \eqn{k_0}
\strong{Variance}: \eqn{0}
\strong{Probability density function (p.d.f)}:
\deqn{
f(x) = 1 for x = k_0
}{
f(x) = 1 for x = k_0
}
\deqn{
f(x) = 0 for x \neq k_0
}{
f(x) = 0 for x \neq k_0
}
\strong{Cumulative distribution function (c.d.f)}:
The cumulative distribution function has the form
\deqn{
F(x) = 0 for x < k_0
}{
F(x) = 0 for x < k_0
}
\deqn{
F(x) = 1 for x \ge k_0
}{
F(x) = 1 for x \ge k_0
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = e^{k_0 t}
}{
E(e^(tX)) = e^(k_0 t)
}
}
\examples{
dist_degenerate(x = 1:5)
}
distributional/man/dist_transformed.Rd 0000644 0001762 0000144 00000002130 14304316336 017716 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/transformed.R
\name{dist_transformed}
\alias{dist_transformed}
\title{Modify a distribution with a transformation}
\usage{
dist_transformed(dist, transform, inverse)
}
\arguments{
\item{dist}{A univariate distribution vector.}
\item{transform}{A function used to transform the distribution. This
transformation should be monotonic over appropriate domain.}
\item{inverse}{The inverse of the \code{transform} function.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}}
The \code{\link[=density]{density()}}, \code{\link[=mean]{mean()}}, and \code{\link[=variance]{variance()}} methods are approximate as
they are based on numerical derivatives.
}
\examples{
# Create a log normal distribution
dist <- dist_transformed(dist_normal(0, 0.5), exp, log)
density(dist, 1) # dlnorm(1, 0, 0.5)
cdf(dist, 4) # plnorm(4, 0, 0.5)
quantile(dist, 0.1) # qlnorm(0.1, 0, 0.5)
generate(dist, 10) # rlnorm(10, 0, 0.5)
}
distributional/man/dist_logistic.Rd 0000644 0001762 0000144 00000003607 14304314270 017214 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_logistic.R
\name{dist_logistic}
\alias{dist_logistic}
\title{The Logistic distribution}
\usage{
dist_logistic(location, scale)
}
\arguments{
\item{location, scale}{location and scale parameters.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
A continuous distribution on the real line. For binary outcomes
the model given by \eqn{P(Y = 1 | X) = F(X \beta)} where
\eqn{F} is the Logistic \code{\link[=cdf]{cdf()}} is called \emph{logistic regression}.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Logistic random variable with
\code{location} = \eqn{\mu} and \code{scale} = \eqn{s}.
\strong{Support}: \eqn{R}, the set of all real numbers
\strong{Mean}: \eqn{\mu}
\strong{Variance}: \eqn{s^2 \pi^2 / 3}
\strong{Probability density function (p.d.f)}:
\deqn{
f(x) = \frac{e^{-(\frac{x - \mu}{s})}}{s [1 + \exp(-(\frac{x - \mu}{s})) ]^2}
}{
f(x) = e^(-(t - \mu) / s) / (s (1 + e^(-(t - \mu) / s))^2)
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{
F(t) = \frac{1}{1 + e^{-(\frac{t - \mu}{s})}}
}{
F(t) = 1 / (1 + e^(-(t - \mu) / s))
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = e^{\mu t} \beta(1 - st, 1 + st)
}{
E(e^(tX)) = = e^(\mu t) \beta(1 - st, 1 + st)
}
where \eqn{\beta(x, y)} is the Beta function.
}
\examples{
dist <- dist_logistic(location = c(5,9,9,6,2), scale = c(2,3,4,2,1))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Logistic]{stats::Logistic}
}
distributional/man/variance.Rd 0000644 0001762 0000144 00000002272 14304316713 016145 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{variance}
\alias{variance}
\alias{variance.numeric}
\alias{variance.matrix}
\alias{covariance.numeric}
\title{Variance}
\usage{
variance(x, ...)
\method{variance}{numeric}(x, ...)
\method{variance}{matrix}(x, ...)
\method{covariance}{numeric}(x, ...)
}
\arguments{
\item{x}{An object.}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
A generic function for computing the variance of an object.
}
\details{
The implementation of \code{variance()} for numeric variables coerces the input to
a vector then uses \code{\link[stats:cor]{stats::var()}} to compute the variance. This means that,
unlike \code{\link[stats:cor]{stats::var()}}, if \code{variance()} is passed a matrix or a 2-dimensional
array, it will still return the variance (\code{\link[stats:cor]{stats::var()}} returns the
covariance matrix in that case).
}
\seealso{
\code{\link[=variance.distribution]{variance.distribution()}}, \code{\link[=covariance]{covariance()}}
}
distributional/man/dist_binomial.Rd 0000644 0001762 0000144 00000005600 14304314267 017172 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_binomial.R
\name{dist_binomial}
\alias{dist_binomial}
\title{The Binomial distribution}
\usage{
dist_binomial(size, prob)
}
\arguments{
\item{size}{The number of trials. Must be an integer greater than or equal
to one. When \code{size = 1L}, the Binomial distribution reduces to the
Bernoulli distribution. Often called \code{n} in textbooks.}
\item{prob}{The probability of success on each trial, \code{prob} can be any
value in \verb{[0, 1]}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Binomial distributions are used to represent situations can that can
be thought as the result of \eqn{n} Bernoulli experiments (here the
\eqn{n} is defined as the \code{size} of the experiment). The classical
example is \eqn{n} independent coin flips, where each coin flip has
probability \code{p} of success. In this case, the individual probability of
flipping heads or tails is given by the Bernoulli(p) distribution,
and the probability of having \eqn{x} equal results (\eqn{x} heads,
for example), in \eqn{n} trials is given by the Binomial(n, p) distribution.
The equation of the Binomial distribution is directly derived from
the equation of the Bernoulli distribution.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
The Binomial distribution comes up when you are interested in the portion
of people who do a thing. The Binomial distribution
also comes up in the sign test, sometimes called the Binomial test
(see \code{\link[stats:binom.test]{stats::binom.test()}}), where you may need the Binomial C.D.F. to
compute p-values.
In the following, let \eqn{X} be a Binomial random variable with parameter
\code{size} = \eqn{n} and \code{p} = \eqn{p}. Some textbooks define \eqn{q = 1 - p},
or called \eqn{\pi} instead of \eqn{p}.
\strong{Support}: \eqn{\{0, 1, 2, ..., n\}}{{0, 1, 2, ..., n}}
\strong{Mean}: \eqn{np}
\strong{Variance}: \eqn{np \cdot (1 - p) = np \cdot q}{np (1 - p)}
\strong{Probability mass function (p.m.f)}:
\deqn{
P(X = k) = {n \choose k} p^k (1 - p)^{n-k}
}{
P(X = k) = choose(n, k) p^k (1 - p)^(n - k)
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{
P(X \le k) = \sum_{i=0}^{\lfloor k \rfloor} {n \choose i} p^i (1 - p)^{n-i}
}{
P(X \le k) = \sum_{i=0}^k choose(n, i) p^i (1 - p)^(n-i)
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = (1 - p + p e^t)^n
}{
E(e^(tX)) = (1 - p + p e^t)^n
}
}
\examples{
dist <- dist_binomial(size = 1:5, prob = c(0.05, 0.5, 0.3, 0.9, 0.1))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
distributional/man/new_hilo.Rd 0000644 0001762 0000144 00000001373 14304316713 016162 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hilo.R
\name{new_hilo}
\alias{new_hilo}
\title{Construct hilo intervals}
\usage{
new_hilo(lower = double(), upper = double(), size = double())
}
\arguments{
\item{lower, upper}{A numeric vector of values for lower and upper limits.}
\item{size}{Size of the interval between [0, 100].}
}
\value{
A "hilo" vector
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Class constructor function to help with manually creating hilo interval
objects.
}
\examples{
new_hilo(lower = rnorm(10), upper = rnorm(10) + 5, size = 95)
}
\author{
Earo Wang & Mitchell O'Hara-Wild
}
distributional/man/dist_beta.Rd 0000644 0001762 0000144 00000001362 14304310476 016312 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_beta.R
\name{dist_beta}
\alias{dist_beta}
\title{The Beta distribution}
\usage{
dist_beta(shape1, shape2)
}
\arguments{
\item{shape1, shape2}{The non-negative shape parameters of the Beta distribution.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_beta(shape1 = c(0.5, 5, 1, 2, 2), shape2 = c(0.5, 1, 3, 2, 5))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Beta]{stats::Beta}
}
distributional/man/support.Rd 0000644 0001762 0000144 00000001050 14304316336 016063 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{support}
\alias{support}
\alias{support.distribution}
\title{Region of support of a distribution}
\usage{
support(x, ...)
\method{support}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
}
distributional/man/kurtosis.Rd 0000644 0001762 0000144 00000001030 14304314326 016225 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{kurtosis}
\alias{kurtosis}
\alias{kurtosis.distribution}
\title{Kurtosis of a probability distribution}
\usage{
kurtosis(x, ...)
\method{kurtosis}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
distributional/man/is_hilo.Rd 0000644 0001762 0000144 00000000356 13703764147 016016 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hilo.R
\name{is_hilo}
\alias{is_hilo}
\title{Is the object a hilo}
\usage{
is_hilo(x)
}
\arguments{
\item{x}{An object.}
}
\description{
Is the object a hilo
}
distributional/man/generate.distribution.Rd 0000644 0001762 0000144 00000001154 14304314270 020657 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{generate.distribution}
\alias{generate.distribution}
\title{Randomly sample values from a distribution}
\usage{
\method{generate}{distribution}(x, times, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{times}{The number of samples.}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Generate random samples from probability distributions.
}
distributional/man/dist_studentized_range.Rd 0000644 0001762 0000144 00000002375 14304314270 021116 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_studentized_range.R
\name{dist_studentized_range}
\alias{dist_studentized_range}
\title{The Studentized Range distribution}
\usage{
dist_studentized_range(nmeans, df, nranges)
}
\arguments{
\item{nmeans}{sample size for range (same for each group).}
\item{df}{degrees of freedom for \eqn{s} (see below).}
\item{nranges}{number of \emph{groups} whose \bold{maximum} range is
considered.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Tukey's studentized range distribution, used for Tukey's
honestly significant differences test in ANOVA.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
\strong{Support}: \eqn{R^+}, the set of positive real numbers.
Other properties of Tukey's Studentized Range Distribution
are omitted, largely because the distribution is not fun
to work with.
}
\examples{
dist <- dist_studentized_range(nmeans = c(6, 2), df = c(5, 4), nranges = c(1, 1))
dist
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Tukey]{stats::Tukey}
}
distributional/man/dist_gumbel.Rd 0000644 0001762 0000144 00000004355 14304314267 016661 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_gumbel.R
\name{dist_gumbel}
\alias{dist_gumbel}
\title{The Gumbel distribution}
\usage{
dist_gumbel(alpha, scale)
}
\arguments{
\item{alpha}{location parameter.}
\item{scale}{parameter. Must be strictly positive.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
The Gumbel distribution is a special case of the Generalized Extreme Value
distribution, obtained when the GEV shape parameter \eqn{\xi} is equal to 0.
It may be referred to as a type I extreme value distribution.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Gumbel random variable with location
parameter \code{mu} = \eqn{\mu}, scale parameter \code{sigma} = \eqn{\sigma}.
\strong{Support}: \eqn{R}, the set of all real numbers.
\strong{Mean}: \eqn{\mu + \sigma\gamma}, where \eqn{\gamma} is Euler's
constant, approximately equal to 0.57722.
\strong{Median}: \eqn{\mu - \sigma\ln(\ln 2)}{\mu - \sigma ln(ln 2)}.
\strong{Variance}: \eqn{\sigma^2 \pi^2 / 6}.
\strong{Probability density function (p.d.f)}:
\deqn{f(x) = \sigma ^ {-1} \exp[-(x - \mu) / \sigma]%
\exp\{-\exp[-(x - \mu) / \sigma] \}}{%
f(x) = (1 / \sigma) exp[-(x - \mu) / \sigma]%
exp{-exp[-(x - \mu) / \sigma]}}
for \eqn{x} in \eqn{R}, the set of all real numbers.
\strong{Cumulative distribution function (c.d.f)}:
In the \eqn{\xi = 0} (Gumbel) special case
\deqn{F(x) = \exp\{-\exp[-(x - \mu) / \sigma] \}}{%
F(x) = exp{ - exp[-(x - \mu) / \sigma]} }
for \eqn{x} in \eqn{R}, the set of all real numbers.
}
\examples{
dist <- dist_gumbel(alpha = c(0.5, 1, 1.5, 3), scale = c(2, 2, 3, 4))
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:Gumbel]{actuar::Gumbel}
}
distributional/man/cdf.Rd 0000644 0001762 0000144 00000001231 14304314270 015077 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{cdf}
\alias{cdf}
\alias{cdf.distribution}
\title{The cumulative distribution function}
\usage{
cdf(x, q, ..., log = FALSE)
\method{cdf}{distribution}(x, q, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{q}{The quantile at which the cdf is calculated.}
\item{...}{Additional arguments passed to methods.}
\item{log}{If \code{TRUE}, probabilities will be given as log probabilities.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
distributional/man/hdr.distribution.Rd 0000644 0001762 0000144 00000001642 14304316336 017651 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{hdr.distribution}
\alias{hdr.distribution}
\title{Highest density regions of probability distributions}
\usage{
\method{hdr}{distribution}(x, size = 95, n = 512, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{size}{The size of the interval (between 0 and 100).}
\item{n}{The resolution used to estimate the distribution's density.}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}}
This function is highly experimental and will change in the future. In
particular, improved functionality for object classes and visualisation tools
will be added in a future release.
Computes minimally sized probability intervals highest density regions.
}
distributional/man/density.distribution.Rd 0000644 0001762 0000144 00000001444 14304314270 020546 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{density.distribution}
\alias{density.distribution}
\title{The probability density/mass function}
\usage{
\method{density}{distribution}(x, at, ..., log = FALSE)
}
\arguments{
\item{x}{The distribution(s).}
\item{at}{The point at which to compute the density/mass.}
\item{...}{Additional arguments passed to methods.}
\item{log}{If \code{TRUE}, probabilities will be given as log probabilities.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Computes the probability density function for a continuous distribution, or
the probability mass function for a discrete distribution.
}
distributional/man/dist_inverse_exponential.Rd 0000644 0001762 0000144 00000001641 14304314270 021454 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_inverse_exponential.R
\name{dist_inverse_exponential}
\alias{dist_inverse_exponential}
\title{The Inverse Exponential distribution}
\usage{
dist_inverse_exponential(rate)
}
\arguments{
\item{rate}{an alternative way to specify the scale.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_inverse_exponential(rate = 1:5)
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:InverseExponential]{actuar::InverseExponential}
}
distributional/man/dist_pareto.Rd 0000644 0001762 0000144 00000001550 14304316335 016670 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_pareto.R
\name{dist_pareto}
\alias{dist_pareto}
\title{The Pareto distribution}
\usage{
dist_pareto(shape, scale)
}
\arguments{
\item{shape, scale}{parameters. Must be strictly positive.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_pareto(shape = c(10, 3, 2, 1), scale = rep(1, 4))
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:Pareto]{actuar::Pareto}
}
distributional/man/family.distribution.Rd 0000644 0001762 0000144 00000001312 14304316335 020346 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{family.distribution}
\alias{family.distribution}
\title{Extract the name of the distribution family}
\usage{
\method{family}{distribution}(object, ...)
}
\arguments{
\item{object}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
}
\examples{
dist <- c(
dist_normal(1:2),
dist_poisson(3),
dist_multinomial(size = c(4, 3),
prob = list(c(0.3, 0.5, 0.2), c(0.1, 0.5, 0.4)))
)
family(dist)
}
distributional/man/variance.distribution.Rd 0000644 0001762 0000144 00000001223 14304314270 020652 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{variance.distribution}
\alias{variance.distribution}
\title{Variance of a probability distribution}
\usage{
\method{variance}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Returns the empirical variance of the probability distribution. If the method
does not exist, the variance of a random sample will be returned.
}
distributional/man/skewness.Rd 0000644 0001762 0000144 00000001030 14304314326 016204 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{skewness}
\alias{skewness}
\alias{skewness.distribution}
\title{Skewness of a probability distribution}
\usage{
skewness(x, ...)
\method{skewness}{distribution}(x, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
distributional/man/dist_logarithmic.Rd 0000644 0001762 0000144 00000001553 14304314270 017677 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_logarithmic.R
\name{dist_logarithmic}
\alias{dist_logarithmic}
\title{The Logarithmic distribution}
\usage{
dist_logarithmic(prob)
}
\arguments{
\item{prob}{parameter. \code{0 <= prob < 1}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_logarithmic(prob = c(0.33, 0.66, 0.99))
dist
\dontshow{if (requireNamespace("actuar", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[actuar:Logarithmic]{actuar::Logarithmic}
}
distributional/man/dist_multinomial.Rd 0000644 0001762 0000144 00000004723 14304316335 017735 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_multinomial.R
\name{dist_multinomial}
\alias{dist_multinomial}
\title{The Multinomial distribution}
\usage{
dist_multinomial(size, prob)
}
\arguments{
\item{size}{The number of draws from the Categorical distribution.}
\item{prob}{The probability of an event occurring from each draw.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
The multinomial distribution is a generalization of the binomial
distribution to multiple categories. It is perhaps easiest to think
that we first extend a \code{\link[=dist_bernoulli]{dist_bernoulli()}} distribution to include more
than two categories, resulting in a \code{\link[=dist_categorical]{dist_categorical()}} distribution.
We then extend repeat the Categorical experiment several (\eqn{n})
times.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X = (X_1, ..., X_k)} be a Multinomial
random variable with success probability \code{p} = \eqn{p}. Note that
\eqn{p} is vector with \eqn{k} elements that sum to one. Assume
that we repeat the Categorical experiment \code{size} = \eqn{n} times.
\strong{Support}: Each \eqn{X_i} is in \eqn{{0, 1, 2, ..., n}}.
\strong{Mean}: The mean of \eqn{X_i} is \eqn{n p_i}.
\strong{Variance}: The variance of \eqn{X_i} is \eqn{n p_i (1 - p_i)}.
For \eqn{i \neq j}, the covariance of \eqn{X_i} and \eqn{X_j}
is \eqn{-n p_i p_j}.
\strong{Probability mass function (p.m.f)}:
\deqn{
P(X_1 = x_1, ..., X_k = x_k) = \frac{n!}{x_1! x_2! ... x_k!} p_1^{x_1} \cdot p_2^{x_2} \cdot ... \cdot p_k^{x_k}
}{
P(X_1 = x_1, ..., X_k = x_k) = n! / (x_1! x_2! ... x_k!) p_1^x_1 p_2^x_2 ... p_k^x_k
}
\strong{Cumulative distribution function (c.d.f)}:
Omitted for multivariate random variables for the time being.
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = \left(\sum_{i=1}^k p_i e^{t_i}\right)^n
}{
E(e^(tX)) = (p_1 e^t_1 + p_2 e^t_2 + ... + p_k e^t_k)^n
}
}
\examples{
dist <- dist_multinomial(size = c(4, 3), prob = list(c(0.3, 0.5, 0.2), c(0.1, 0.5, 0.4)))
dist
mean(dist)
variance(dist)
generate(dist, 10)
# TODO: Needs fixing to support multiple inputs
# density(dist, 2)
# density(dist, 2, log = TRUE)
}
\seealso{
\link[stats:Multinom]{stats::Multinomial}
}
distributional/man/dist_student_t.Rd 0000644 0001762 0000144 00000004405 14304314270 017405 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_student_t.R
\name{dist_student_t}
\alias{dist_student_t}
\title{The (non-central) location-scale Student t Distribution}
\usage{
dist_student_t(df, mu = 0, sigma = 1, ncp = NULL)
}
\arguments{
\item{df}{degrees of freedom (\eqn{> 0}, maybe non-integer). \code{df
= Inf} is allowed.}
\item{mu}{The location parameter of the distribution.
If \code{ncp == 0} (or \code{NULL}), this is the median.}
\item{sigma}{The scale parameter of the distribution.}
\item{ncp}{non-centrality parameter \eqn{\delta}{delta};
currently except for \code{rt()}, only for \code{abs(ncp) <= 37.62}.
If omitted, use the central t distribution.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
The Student's T distribution is closely related to the \code{\link[=Normal]{Normal()}}
distribution, but has heavier tails. As \eqn{\nu} increases to \eqn{\infty},
the Student's T converges to a Normal. The T distribution appears
repeatedly throughout classic frequentist hypothesis testing when
comparing group means.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a \strong{central} Students T random variable
with \code{df} = \eqn{\nu}.
\strong{Support}: \eqn{R}, the set of all real numbers
\strong{Mean}: Undefined unless \eqn{\nu \ge 2}, in which case the mean is
zero.
\strong{Variance}:
\deqn{
\frac{\nu}{\nu - 2}
}{
\nu / (\nu - 2)
}
Undefined if \eqn{\nu < 1}, infinite when \eqn{1 < \nu \le 2}.
\strong{Probability density function (p.d.f)}:
\deqn{
f(x) = \frac{\Gamma(\frac{\nu + 1}{2})}{\sqrt{\nu \pi} \Gamma(\frac{\nu}{2})} (1 + \frac{x^2}{\nu} )^{- \frac{\nu + 1}{2}}
}{
f(x) = \Gamma((\nu + 1) / 2) / (\sqrt(\nu \pi) \Gamma(\nu / 2)) (1 + x^2 / \nu)^(- (\nu + 1) / 2)
}
}
\examples{
dist <- dist_student_t(df = c(1,2,5), mu = c(0,1,2), sigma = c(1,2,3))
dist
mean(dist)
variance(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:TDist]{stats::TDist}
}
distributional/man/hilo.distribution.Rd 0000644 0001762 0000144 00000001565 14304316336 020033 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/distribution.R
\name{hilo.distribution}
\alias{hilo.distribution}
\title{Probability intervals of a probability distribution}
\usage{
\method{hilo}{distribution}(x, size = 95, ...)
}
\arguments{
\item{x}{The distribution(s).}
\item{size}{The size of the interval (between 0 and 100).}
\item{...}{Additional arguments used by methods.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Returns a \code{hilo} central probability interval with probability coverage of
\code{size}. By default, the distribution's \code{\link[=quantile]{quantile()}} will be used to compute
the lower and upper bound for a centered interval
}
\seealso{
\code{\link[=hdr.distribution]{hdr.distribution()}}
}
distributional/man/dist_exponential.Rd 0000644 0001762 0000144 00000001306 14304314267 017725 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_exponential.R
\name{dist_exponential}
\alias{dist_exponential}
\title{The Exponential Distribution}
\usage{
dist_exponential(rate)
}
\arguments{
\item{rate}{vector of rates.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_exponential(rate = c(2, 1, 2/3))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Exponential]{stats::Exponential}
}
distributional/man/dist_f.Rd 0000644 0001762 0000144 00000003447 14304314267 015634 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_f.R
\name{dist_f}
\alias{dist_f}
\title{The F Distribution}
\usage{
dist_f(df1, df2, ncp = NULL)
}
\arguments{
\item{df1, df2}{degrees of freedom. \code{Inf} is allowed.}
\item{ncp}{non-centrality parameter. If omitted the central F is assumed.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Gamma random variable
with parameters
\code{shape} = \eqn{\alpha} and
\code{rate} = \eqn{\beta}.
\strong{Support}: \eqn{x \in (0, \infty)}
\strong{Mean}: \eqn{\frac{\alpha}{\beta}}
\strong{Variance}: \eqn{\frac{\alpha}{\beta^2}}
\strong{Probability density function (p.m.f)}:
\deqn{
f(x) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x}
}{
f(x) = \frac{\beta^{\alpha}}{\Gamma(\alpha)} x^{\alpha - 1} e^{-\beta x}
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{
f(x) = \frac{\Gamma(\alpha, \beta x)}{\Gamma{\alpha}}
}{
f(x) = \frac{\Gamma(\alpha, \beta x)}{\Gamma{\alpha}}
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta
}{
E(e^(tX)) = \Big(\frac{\beta}{ \beta - t}\Big)^{\alpha}, \thinspace t < \beta
}
}
\examples{
dist <- dist_f(df1 = c(1,2,5,10,100), df2 = c(1,1,2,1,100))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
\seealso{
\link[stats:Fdist]{stats::FDist}
}
distributional/man/dist_bernoulli.Rd 0000644 0001762 0000144 00000004345 14304314267 017400 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_bernoulli.R
\name{dist_bernoulli}
\alias{dist_bernoulli}
\title{The Bernoulli distribution}
\usage{
dist_bernoulli(prob)
}
\arguments{
\item{prob}{The probability of success on each trial, \code{prob} can be any
value in \verb{[0, 1]}.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
Bernoulli distributions are used to represent events like coin flips
when there is single trial that is either successful or unsuccessful.
The Bernoulli distribution is a special case of the \code{\link[=Binomial]{Binomial()}}
distribution with \code{n = 1}.
}
\details{
We recommend reading this documentation on
\url{https://pkg.mitchelloharawild.com/distributional/}, where the math
will render nicely.
In the following, let \eqn{X} be a Bernoulli random variable with parameter
\code{p} = \eqn{p}. Some textbooks also define \eqn{q = 1 - p}, or use
\eqn{\pi} instead of \eqn{p}.
The Bernoulli probability distribution is widely used to model
binary variables, such as 'failure' and 'success'. The most
typical example is the flip of a coin, when \eqn{p} is thought as the
probability of flipping a head, and \eqn{q = 1 - p} is the
probability of flipping a tail.
\strong{Support}: \eqn{\{0, 1\}}{{0, 1}}
\strong{Mean}: \eqn{p}
\strong{Variance}: \eqn{p \cdot (1 - p) = p \cdot q}{p (1 - p)}
\strong{Probability mass function (p.m.f)}:
\deqn{
P(X = x) = p^x (1 - p)^{1-x} = p^x q^{1-x}
}{
P(X = x) = p^x (1 - p)^(1-x)
}
\strong{Cumulative distribution function (c.d.f)}:
\deqn{
P(X \le x) =
\left \{
\begin{array}{ll}
0 & x < 0 \\
1 - p & 0 \leq x < 1 \\
1 & x \geq 1
\end{array}
\right.
}{
P(X \le x) = (1 - p) 1_{[0, 1)}(x) + 1_{1}(x)
}
\strong{Moment generating function (m.g.f)}:
\deqn{
E(e^{tX}) = (1 - p) + p e^t
}{
E(e^(tX)) = (1 - p) + p e^t
}
}
\examples{
dist <- dist_bernoulli(prob = c(0.05, 0.5, 0.3, 0.9, 0.1))
dist
mean(dist)
variance(dist)
skewness(dist)
kurtosis(dist)
generate(dist, 10)
density(dist, 2)
density(dist, 2, log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
}
distributional/man/dist_multivariate_normal.Rd 0000644 0001762 0000144 00000002150 14304316335 021451 0 ustar ligges users % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/dist_multivariate_normal.R
\name{dist_multivariate_normal}
\alias{dist_multivariate_normal}
\title{The multivariate normal distribution}
\usage{
dist_multivariate_normal(mu = 0, sigma = diag(1))
}
\arguments{
\item{mu}{A list of numeric vectors for the distribution's mean.}
\item{sigma}{A list of matrices for the distribution's variance-covariance matrix.}
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#stable}{\figure{lifecycle-stable.svg}{options: alt='[Stable]'}}}{\strong{[Stable]}}
}
\examples{
dist <- dist_multivariate_normal(mu = list(c(1,2)), sigma = list(matrix(c(4,2,2,3), ncol=2)))
dist
\dontshow{if (requireNamespace("mvtnorm", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
mean(dist)
variance(dist)
support(dist)
generate(dist, 10)
density(dist, c(2, 1))
density(dist, c(2, 1), log = TRUE)
cdf(dist, 4)
quantile(dist, 0.7)
\dontshow{\}) # examplesIf}
}
\seealso{
\link[mvtnorm:Mvnorm]{mvtnorm::dmvnorm}, \link[mvtnorm:qmvnorm]{mvtnorm::qmvnorm}
}
distributional/man/figures/ 0000755 0001762 0000144 00000000000 14406447336 015540 5 ustar ligges users distributional/man/figures/lifecycle-defunct.svg 0000644 0001762 0000144 00000001704 14304310441 021627 0 ustar ligges users