buffon.needle: Simulating Buffon's Needles Experiment

Description Usage Arguments Details Value Author(s) Examples

Description

This function takes as arguments the number of needles n, the length of needle l and the distance between the lines d, then simulate the buffon needle experiment.

Usage

1
buffon.needle(n=255,l= 2.5, d=3, ind = FALSE, plot= FALSE )

Arguments

n

the number of needles

l

the length of the needles

d

the distance between two lines

ind

specicfies whether or not to give a red color to the needles that hit the lines

plot

specifies whether the board should be drawn.

Details

The idea is to generate two random points (x,k) and (xmax, kmax) represents the points which the needle extends. Any point (x,k) on the board is uniformly distributed, by the assumption that it is equally likely to hit any point on the board. At the same time an angle theta is generated from U(0, pi/2). Using this angle the point (xmax,kmax) is generated since xmax = x+l*sin(theta) and kmax = k + l*cos(theta).

The board is designed such that there are 5 parallel lines, distance d from each other i.e we have y_1= d, y_2 = 2*d,...,y_5 = 5*d. Every time there is a hit it satisfies that kmax > y_i > k.

Value

An estimation of Pi using the famous buffon's experiment

Author(s)

Nguyen Khanh Le Ho

Examples

1
buffon.needle(n=2000, l= 2.5 , d= 3 ,  ind = TRUE, plot=TRUE )

Honguyen14/anything documentation built on May 7, 2019, 4:02 a.m.