Skip to contents

The Chapter 3 example. Each replication throws n uniform points at the square \([-1, 1]^2\) and estimates \(\pi\) as four times the fraction that land inside the unit circle.

Usage

pi_worker(n, set_up, ...)

Arguments

n

Sample size for each replication.

set_up

One element of make_set_up().

...

Ignored.

Value

A numeric vector of set_up$n_reps estimates of \(\pi\).

See also

Examples

out <- sim_template(pi_worker, 1234, 100, 1000, 2)
mean(bind_results(out))
#> [1] 3.14924