To pass the check:

  1. the object must be a numeric vector

  2. its elements must sum to 1

  3. it must not contain any strictly-negative value.

  4. (optionally) it must not contain NAs.

.check_is_probability_distr_vector(
  distribution,
  tolerate_NAs = FALSE,
  tolerance_on_sum = 0.01,
  parameter_name = deparse(substitute(distribution))
)

Arguments

distribution

Input for which we need to check that it is a proper probability distribution.

tolerate_NAs

Can the distribution contain NA values?

tolerance_on_sum

Numeric tolerance in checking that vector elements sum to 1.

parameter_name

A string containing the name the tested parameter had in the initial function in which it was passed.

Value

TRUE if all tests were passed. Throws an error otherwise.