Skip to contents

These functions check whether the input fulfills the properties of a probability matrix.

Usage

check_probability_vector(x, len = NULL, tolerance = sqrt(.Machine$double.eps))

assert_probability_vector(
  x,
  len = NULL,
  tolerance = sqrt(.Machine$double.eps),
  .var.name = checkmate::vname(x),
  add = NULL
)

test_probability_vector(x, len = NULL, tolerance = sqrt(.Machine$double.eps))

Arguments

x

[any]
Object to check.

len

[integer(1)]
Exact expected length of x.

tolerance

[numeric(1)]
A non-negative tolerance value.

.var.name

[character(1)]
Name of the checked object to print in assertions. Defaults to the heuristic implemented in vname.

add

[AssertCollection]
Collection to store assertion messages. See AssertCollection.

Value

Same as documented in check_numeric.

Examples

p <- c(0.2, 0.3, 0.6)
check_probability_vector(p)
#> [1] "Must add up to 1"
test_probability_vector(p)
#> [1] FALSE
if (FALSE) { # \dontrun{
assert_probability_vector(p)
} # }