Print method for accept_reject objects.
Usage
# S3 method for accept_reject
print(x, n_min = 10L, ...)Arguments
- x
An accept_reject object.
- n_min
Minimum number of observations to print.
- ...
Additional arguments.
Value
An object of class character, providing a formatted output with some
information about the accept_reject object, including the number of
observations, the value of the constant \(c\) that maximizes acceptance, and
the acceptance probability \(1/c\). Additionally, it prints the first
generated observations. The function print.accept_reject() enables
formatting when executing an object of class 'accept_reject' in the console
or when executing the function print() on an object of class
accept_reject, returned by the function accept_reject().
Details
The function print.accept_reject() is responsible for printing an object of
class accept_reject in a formatted manner, providing some information
about the accept_reject object, including the number of observations, the
value of the constant \(c\) that maximizes acceptance, and the acceptance
probability \(1/c\). Additionally, it prints the first generated
observations. The function print.accept_reject() delivers formatted output
when executing an object of class accept_reject in the console or when
executing the function print() on an object of class accept_reject,
returned by the function accept_reject().
Examples
set.seed(0) # setting a seed for reproducibility
x = accept_reject(
n = 2000L,
f = dbinom,
continuous = FALSE,
args_f = list(size = 10, prob = 0.5),
xlim = c(0, 10)
)
print(x)
#>
#> ── Accept-Reject Samples ───────────────────────────────────────────────────────
#>
#> ℹ It's not necessary, but if you want to extract the observations, use as.vector().
#>
#> ✔ Case: discrete
#> ✔ Number of observations: 2000
#> ✔ c: 2.4609
#> ✔ Probability of acceptance (1/c): 0.4063
#> ✔ Observations: 3 6 6 4 4 5 4 4 4 5...
#> ✔ xlim = 0 10
#>
#> ────────────────────────────────────────────────────────────────────────────────
