Skip to contents

A full-flexibility discrete distribution with values from 1 to size.

Usage

dist_discrete(size = NULL, probs = NULL)

Arguments

size

Number of classes parameter (integer). Required if probs is NULL.

probs

Vector of probabilties parameter, or NULL as a placeholder.

Value

A DiscreteDistribution object.

Details

Parameters can be overridden with with_params = list(probs = ...).

Examples

d_discrete <- dist_discrete(probs = list(0.5, 0.25, 0.15, 0.1))
x <- d_discrete$sample(100)
d_emp <- dist_empirical(x)

plot_distributions(
  empirical = d_emp,
  theoretical = d_discrete,
  estimated = d_discrete,
  with_params = list(
    estimated = list(
      size = max(x),
      probs = as.list(unname(table(x)) / 100)
    )
  ),
  .x = 0:max(x)
)