Skip to contents

Compute expected hits from a size measure, or extract them from a with-replacement design object.

Usage

expected_hits(x, ...)

# Default S3 method
expected_hits(x, n, ...)

# S3 method for class 'wr'
expected_hits(x, ...)

# S3 method for class 'wor'
expected_hits(x, ...)

Arguments

x

A numeric vector of positive size measures, or a with-replacement design object (class "wr").

...

Additional arguments (currently unused).

n

The desired sample size. Required when x is a numeric vector, ignored when x is a design object.

Value

A numeric vector of expected hits (may exceed 1 for WR designs).

See also

inclusion_prob() for the without-replacement analogue, unequal_prob_wr() for sampling with expected hits.

Examples

# From size measures
x <- c(40, 80, 50, 60, 70)
hits <- expected_hits(x, n = 3)
sum(hits)  # 3
#> [1] 3

# From a design object
s <- unequal_prob_wr(hits, method = "chromy")
expected_hits(s)
#> [1] 0.4 0.8 0.5 0.6 0.7