MonteCarlo: Monte Carlo

View source: R/chapter2.R

MonteCarloR Documentation

Monte Carlo

Description

This function implements Monte Carlo integration with n steps, estimating the area of a function, f, under the unit square. With sample_y = TRUE, the default, the method in the text is used. With sample_y = FALSE, the x points are sampled but f(x) is directly evaluated.

Usage

MonteCarlo(n, f = function(x) x^2, sample_y = TRUE)

tteravai/IntroProbR documentation built on July 31, 2023, 3:31 a.m.