Skip to contents

An empirical distribution is a non-parametric way to estimate a distribution using data. By default, it assigns equal probability to all observations (this can be overridden with the weights argument). Identical to dst_finite() with weights as probabilities, except weights need not add to 1.

Usage

dst_empirical(y, data, weights = 1, ...)

Arguments

y

<data-masking> Outcomes to comprise the distribution. Should either evaluate to an (atomic) vector, or be a name in the specified data.

data

Data frame containing the outcomes y and/or weights. Optional.

weights

<data-masking> Weights to assign each outcome in y. Will be normalized so that the weights add up to 1 (unlike dst_finite()), representing probabilities.

...

Additional arguments, currently not used.

Value

An object of class c("finite", "dst").

See also

Examples

x <- rnorm(100)
dst_empirical(x)
#> [1] "finite" "dst"   
#> 
#>  probabilities :
#> # A tibble: 100 × 2
#>    location  size
#>       <dbl> <dbl>
#>  1    -2.61  0.01
#>  2    -2.44  0.01
#>  3    -2.27  0.01
#>  4    -1.91  0.01
#>  5    -1.91  0.01
#>  6    -1.86  0.01
#>  7    -1.82  0.01
#>  8    -1.70  0.01
#>  9    -1.63  0.01
#> 10    -1.51  0.01
#> # ℹ 90 more rows
dst_empirical(value, data = data.frame(value = x))
#> [1] "finite" "dst"   
#> 
#>  probabilities :
#> # A tibble: 100 × 2
#>    location  size
#>       <dbl> <dbl>
#>  1    -2.61  0.01
#>  2    -2.44  0.01
#>  3    -2.27  0.01
#>  4    -1.91  0.01
#>  5    -1.91  0.01
#>  6    -1.86  0.01
#>  7    -1.82  0.01
#>  8    -1.70  0.01
#>  9    -1.63  0.01
#> 10    -1.51  0.01
#> # ℹ 90 more rows