hmplot: Plot Monte-Carlo integration using the hit and miss method

Description Usage Arguments References See Also Examples

Description

Partially vectorised version.

Usage

1
hmplot(ftn, a, b, c, d, n)

Arguments

ftn

a function of single variable.

a

lower bound of the integration. Must be finite.

b

upper bound of the integration. Must be finite and assume b > a.

c

lower bound of the ftn over the range [a,b].

d

upper bound of the ftn over the range [a,b].

n

number of samples used in the estimation.

References

Owen Jones,Robert Maillardet,Andrew Robinson (2014).Introduction to Scientific Programming and Simulation Using R ; Second Edition

See Also

plot

Examples

1
2
3
4
## We have added a line to plot the successive approximations to the integral.
f <- function(x) return(x^3 - 7 * x^2 + 1 )
hmplot(f, 0, 1, -6, 2, 10000)
lines(c(0, 10000), c(-13/12, -13/12))

david850803/MC.makes.perfect documentation built on June 16, 2019, 12:04 a.m.