Skip to contents

Helpers and Constructors from ffp.

Usage

ffp(x = double(), ...)

is_ffp(x)

as_ffp(x)

# S3 method for default
as_ffp(x)

# S3 method for integer
as_ffp(x)

Arguments

x
  • For ffp(): A numeric vector.

  • For is_ffp(): An object to be tested.

  • For as_ffp(): An object to convert to ffp.

...

Additional attributes to be passed to ffp.

Value

  • ffp() and as_ffp() return an S3 vector of class ffp (built upon double's);

  • is_ffp() returns a logical object.

Details

The ffp class is designed to interact with doubles, but the output of c(ffp, double) or c(double, ffp) will always return a double (not an ffp object), since there is no way to guarantee the interaction between a numeric vector and a probability will also be a probability.

Examples

set.seed(123)
p <- runif(5)
p <- p / sum(p)

is_ffp(p)
#> [1] FALSE
as_ffp(p)
#> <ffp[5]>
#> 0.08692491 0.2382778 0.1236198 0.2669061 0.2842713