hit_miss: Monte-Carlo integration using the hit and miss method

Description Usage Arguments References See Also Examples

Description

Monte-Carlo integration using the hit and miss method

Usage

1
hit_miss(ftn, a, b, f.min, f.max, 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.

f.min

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

f.max

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

integrate

Examples

1
2
3
4
5
6
7
## We see that the number of repetitions n needs to be very large
## in order to get even just two decimal places of accuracy.
f <- function(x) return(x^3 - 7 * x^2 + 1 )
hit_miss(f, 0, 1, -6, 2, 1000)
hit_miss(f, 0, 1, -6, 2, 10000)
hit_miss(f, 0, 1, -6, 2, 100000)
hit_miss(f, 0, 1, -6, 2, 1000000)

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