Learn R Programming

mcsm (version 1.0)

betagen: Plot explaining accept-reject on a Beta(2.7,6.3) target

Description

This function of Nsim represents Nsim points simulated from either a uniform or a Beta(2,6) proposal in terms of their location above versus below the density of the Beta(2.7,6.3) target in order to explain accept-reject methods.

Usage

betagen(Nsim = 10^3)

Arguments

Nsim
Number of points to be represented on the subgraph, the default value being $10^3$

Value

The function returns a graph, either on an existing graphical window or by creating a new graphical window, with two plots side-by-side.

Warning

This function is only intended to illustrate the principle at work behind accept-reject. For Beta simulation, use rbeta.

Details

The R code can be modified for further use, but note that the bounds M in the program are hardcoded towards the current values of a and b.

References

Chapter 3 of EnteR Monte Carlo Statistical Methods

See Also

rbeta

Examples

Run this code
betagen(Nsim=10^4)

Run the code above in your browser using DataLab