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.

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)
#> finite dst
#> 
#>  probabilities :
#> # A tibble: 100 × 2
#>    location  size
#>       <dbl> <dbl>
#>  1    -3.16  0.01
#>  2    -2.16  0.01
#>  3    -1.84  0.01
#>  4    -1.76  0.01
#>  5    -1.69  0.01
#>  6    -1.65  0.01
#>  7    -1.55  0.01
#>  8    -1.45  0.01
#>  9    -1.36  0.01
#> 10    -1.18  0.01
#> # … with 90 more rows
dst_empirical(value, data = data.frame(value = x))
#> finite dst
#> 
#>  probabilities :
#> # A tibble: 100 × 2
#>    location  size
#>       <dbl> <dbl>
#>  1    -3.16  0.01
#>  2    -2.16  0.01
#>  3    -1.84  0.01
#>  4    -1.76  0.01
#>  5    -1.69  0.01
#>  6    -1.65  0.01
#>  7    -1.55  0.01
#>  8    -1.45  0.01
#>  9    -1.36  0.01
#> 10    -1.18  0.01
#> # … with 90 more rows