SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
Buffon’s needle(s)
1. Write an R function called dart(n,t,l) that (a) throws uniformly n points (x, y) inside the
square [−1, 1] × [−1, 1] and (b) returns the proportion of points within the unit circle,
x2 + y 2 ≤ 1. Use dart to derive an approximation of the constant π by this experiment
and plot the evolutions of the approximation when the number n of dots grows from 10
to 105 .
Buffon’s needle is one of the earliest instances of using simulation to approximate an integral.
It uses random throws of needles of length over a wooden floor made of planks of width t ≥
and derives the constant π from the proportion of needles crossing a plank separation (or line).
This model assumes all planks are identical, horizontal, and parallel.
2. If we assume that the centre of the needle falls between two lines with uniform probability,
show (or use the fact) that the probability that this centre stands within a distance /2
of the closest line is /t.
3. Conditioning on the event that the centre of the needle is within /2 of the closest line of
the plank and assuming that the needle is oriented uniformly over (0, π) with respect to
the axis of the line, show (or use the fact) that the probability that the needle crosses the
closest line is 2/π.
4. Conclude that the overall probability that the needle crosses the closest line is 2 /tπ.
5. If A and B are the coordinates of the extremities of a random needle, show that it crosses
a line if and only if the boolean
(trunc(A[,2]) != trunc(B[,2]))
is true.
6. Write an R code buffon(l,t,n) that approximate this probability by throwing n centres
uniformly at random over the [−10t, 10t] × [−10t, 10t] unit square (which contains 19
lines), then generating the angles of the n needles of length l wrt the line uniformly over
(0, π) and counting how many needles cross a line. Run this code for n = 105 needles and
check whether or not π belongs to the Monte Carlo confidence interval.
7. Expand your R code buffon(l,t,n) to plot the plank separations and the random needles
on top of those.
8. Implement the following R code :
BuffonsNeedle <- function(n=100, sd=2){
#(C.) Allan Roberts, 2013.
X <- rnorm(n,5,sd)
Y <- rnorm(n,5,sd)
Angle <- runif(n,0,2*pi)
X2 <- X + cos(Angle)
Y2 <- Y + sin(Angle)
CrossesLine <- ( floor(Y) != floor(Y2) )
p <- sum(CrossesLine)/n
return(c(p,2/p))
}
(a) Explain why (or accept the fact that) this R code is only an approximation to Buffon’s
problem.
1
(b) Identify from the R code what the corresponding values of

and t are.

(c) For n = 105 , give a confidence interval on π and check whether π belongs to this
interval.
(d) Repeat the above verification with sd=0.2, then with sd=.002.

0.1

More Buffon’s needles

1. If X, Y are normal N (0, 1) rv’s, show (or use the fact) that the probability that X 2 +Y 2 ≤ 1
is equal to
√
P(X 2 + Y 2 ≤ 1) = 1 − 1/ e
2. Write an R function called hitin(n) that (a) throws n points (x, y) from the standard
bivariate normal distribution N2 (0, I) and (b) returns the proportion of points within the
unit circle x2 + y 2 ≤ 1. Use hitin to derive an approximation of the constant e by this
experiment and plot the evolution of the approximation when the number n of dots grows
√
from 10 to 106 . Provide a confidence interval that has a 95% probability to contain 1/ e.
3. We now consider Buffon’s needle experiment, where metal needles of length are thrown
upon a wooden floor made of planks of width t ≥ and where the number of times the
needles cross a plank separation (or line) is counted. The resulting proportion leads to an
approximation of π. (This model assumes all planks are identical, parallel, and horizontal.)
(a) We assume that the centre of the needle falls uniformly over a large room, meaning
that the second component is uniform over [−D × t, D × t], where 1
D. And that
the orientation of the needle is uniform over (0, π). In that case, show (or use the
fact) that the probability of crossing a line is line is 2 /tπ.
(b) If A and B are the coordinates of the extremities of a random needle, show that it
crosses a line if and only if the boolean
(trunc(A[,2]) != trunc(B[,2]))
takes the value TRUE.
(c) Write an R code buffon(l,t,n,D) that approximate this probability by throwing n
centres uniformly at random over the [−D × t, D × t] × [−D × t, D × t] unit square
(which contains 2D1 lines), then generating the angles of the n needles wrt the line
uniformly over (0, π) and counting how many needles cross a line.
(d) Study the evolution of the approximation of π as n = 104 and as D decreases from
D = 100 to D = 3 by plotting several independent approximations for each value of
D you consider.
(e) Expand your R code buffon(l,t,n,D) to plot the lines and the random needles.
4. Implement the following R code :
BuffonsNeedle <- function(N=1000,D=50,L=.25){
# warning: L is the half-length
numbhits <- function(A,B){
sum(abs(trunc(A[,2])-trunc(B[,2]))>0)}
O <- runif(N,min=0,max=pi/2) #angle
U <- L+runif(N)*(D*sqrt(1+apply(cbind(sin(O)^2,cos(O)^2),1,min))-2*L)
C <- cbind(U*cos(O),U*sin(O)) # centre
2
A <- C+L*cbind(cos(O),sin(O)) # endpoint A
B <- C-L*cbind(cos(O),sin(O)) # endpoint B
return(2*2*L*N/numbhits(A,B))
}
(a) Explain why this R code is only approximately solving Buffon’s original problem and
identify from the R code what the corresponding values of and t are.
(b) Study how the corresponding approximation of π converges with N .
(c) Repeat the study with D=100, then with D=10.

3

Mais conteúdo relacionado

Mais procurados (19)

Calc 2.1
Calc 2.1Calc 2.1
Calc 2.1
 
MEAN VALUE THEOREM
MEAN VALUE THEOREMMEAN VALUE THEOREM
MEAN VALUE THEOREM
 
8.further calculus Further Mathematics Zimbabwe Zimsec Cambridge
8.further calculus   Further Mathematics Zimbabwe Zimsec Cambridge8.further calculus   Further Mathematics Zimbabwe Zimsec Cambridge
8.further calculus Further Mathematics Zimbabwe Zimsec Cambridge
 
25285 mws gen_int_ppt_trapcontinuous
25285 mws gen_int_ppt_trapcontinuous25285 mws gen_int_ppt_trapcontinuous
25285 mws gen_int_ppt_trapcontinuous
 
Mean value theorem
Mean value theoremMean value theorem
Mean value theorem
 
Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)Lesson 19: The Mean Value Theorem (slides)
Lesson 19: The Mean Value Theorem (slides)
 
Arrays cpu2
Arrays cpu2Arrays cpu2
Arrays cpu2
 
Mean Value Theorems
Mean Value TheoremsMean Value Theorems
Mean Value Theorems
 
Numerical integration
Numerical integrationNumerical integration
Numerical integration
 
ppt of Calculus
ppt of Calculusppt of Calculus
ppt of Calculus
 
21 simpson's rule
21 simpson's rule21 simpson's rule
21 simpson's rule
 
Calc 3.2b
Calc 3.2bCalc 3.2b
Calc 3.2b
 
MATH225Final
MATH225FinalMATH225Final
MATH225Final
 
Roll's theorem
Roll's theoremRoll's theorem
Roll's theorem
 
Bisection method
Bisection methodBisection method
Bisection method
 
Trapezoidal Method IN Numerical Analysis
Trapezoidal Method IN  Numerical AnalysisTrapezoidal Method IN  Numerical Analysis
Trapezoidal Method IN Numerical Analysis
 
Integration
IntegrationIntegration
Integration
 
Derivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 ruleDerivation of Simpson's 1/3 rule
Derivation of Simpson's 1/3 rule
 
Maxima & Minima for IIT JEE | askIITians
Maxima & Minima for IIT JEE | askIITiansMaxima & Minima for IIT JEE | askIITians
Maxima & Minima for IIT JEE | askIITians
 

Semelhante a Buffon's needle exercises

Engr 371 final exam april 1996
Engr 371 final exam april 1996Engr 371 final exam april 1996
Engr 371 final exam april 1996amnesiann
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homographyShih-Hsiang Lin
 
15.) Line L in the figure below is parallel to the line y=.docx
15.) Line L in the figure below is parallel to the line y=.docx15.) Line L in the figure below is parallel to the line y=.docx
15.) Line L in the figure below is parallel to the line y=.docxherminaprocter
 
Nbhm m. a. and m.sc. scholarship test 2011
Nbhm m. a. and m.sc. scholarship test 2011Nbhm m. a. and m.sc. scholarship test 2011
Nbhm m. a. and m.sc. scholarship test 2011MD Kutubuddin Sardar
 
The Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxThe Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxmattinsonjanel
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanationsGopi Saiteja
 
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfMA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfvasusingh34
 
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfMA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfvasusingh34
 
2008 worldfinalsproblemset
2008 worldfinalsproblemset2008 worldfinalsproblemset
2008 worldfinalsproblemsetLuca Zannini
 
The Probability that a Matrix of Integers Is Diagonalizable
The Probability that a Matrix of Integers Is DiagonalizableThe Probability that a Matrix of Integers Is Diagonalizable
The Probability that a Matrix of Integers Is DiagonalizableJay Liew
 
Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006MD Kutubuddin Sardar
 
Fourier-transform analysis of a unilateral fin line and its derivatives
Fourier-transform analysis of a unilateral fin line and its derivativesFourier-transform analysis of a unilateral fin line and its derivatives
Fourier-transform analysis of a unilateral fin line and its derivativesYong Heui Cho
 
An Optimal Solution For The Channel-Assignment Problem
An Optimal Solution For The Channel-Assignment ProblemAn Optimal Solution For The Channel-Assignment Problem
An Optimal Solution For The Channel-Assignment ProblemSarah Morrow
 

Semelhante a Buffon's needle exercises (20)

Engr 371 final exam april 1996
Engr 371 final exam april 1996Engr 371 final exam april 1996
Engr 371 final exam april 1996
 
Introduction to homography
Introduction to homographyIntroduction to homography
Introduction to homography
 
15.) Line L in the figure below is parallel to the line y=.docx
15.) Line L in the figure below is parallel to the line y=.docx15.) Line L in the figure below is parallel to the line y=.docx
15.) Line L in the figure below is parallel to the line y=.docx
 
Nbhm m. a. and m.sc. scholarship test 2011
Nbhm m. a. and m.sc. scholarship test 2011Nbhm m. a. and m.sc. scholarship test 2011
Nbhm m. a. and m.sc. scholarship test 2011
 
The Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docxThe Catholic University of America School of Engineering .docx
The Catholic University of America School of Engineering .docx
 
Test
TestTest
Test
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfMA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
 
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdfMA101-Lecturenotes(2019-20)-Module 13 (1).pdf
MA101-Lecturenotes(2019-20)-Module 13 (1).pdf
 
SinogramReconstruction
SinogramReconstructionSinogramReconstruction
SinogramReconstruction
 
Distance function
Distance functionDistance function
Distance function
 
dsp
dspdsp
dsp
 
Unit 3
Unit 3Unit 3
Unit 3
 
Unit 3
Unit 3Unit 3
Unit 3
 
2008 worldfinalsproblemset
2008 worldfinalsproblemset2008 worldfinalsproblemset
2008 worldfinalsproblemset
 
The Probability that a Matrix of Integers Is Diagonalizable
The Probability that a Matrix of Integers Is DiagonalizableThe Probability that a Matrix of Integers Is Diagonalizable
The Probability that a Matrix of Integers Is Diagonalizable
 
Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006Nbhm m. a. and m.sc. scholarship test 2006
Nbhm m. a. and m.sc. scholarship test 2006
 
Fourier-transform analysis of a unilateral fin line and its derivatives
Fourier-transform analysis of a unilateral fin line and its derivativesFourier-transform analysis of a unilateral fin line and its derivatives
Fourier-transform analysis of a unilateral fin line and its derivatives
 
Networking Assignment Help
Networking Assignment HelpNetworking Assignment Help
Networking Assignment Help
 
An Optimal Solution For The Channel-Assignment Problem
An Optimal Solution For The Channel-Assignment ProblemAn Optimal Solution For The Channel-Assignment Problem
An Optimal Solution For The Channel-Assignment Problem
 

Mais de Christian Robert

Asymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceAsymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceChristian Robert
 
Workshop in honour of Don Poskitt and Gael Martin
Workshop in honour of Don Poskitt and Gael MartinWorkshop in honour of Don Poskitt and Gael Martin
Workshop in honour of Don Poskitt and Gael MartinChristian Robert
 
How many components in a mixture?
How many components in a mixture?How many components in a mixture?
How many components in a mixture?Christian Robert
 
Testing for mixtures at BNP 13
Testing for mixtures at BNP 13Testing for mixtures at BNP 13
Testing for mixtures at BNP 13Christian Robert
 
Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Christian Robert
 
Testing for mixtures by seeking components
Testing for mixtures by seeking componentsTesting for mixtures by seeking components
Testing for mixtures by seeking componentsChristian Robert
 
discussion on Bayesian restricted likelihood
discussion on Bayesian restricted likelihooddiscussion on Bayesian restricted likelihood
discussion on Bayesian restricted likelihoodChristian Robert
 
NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)Christian Robert
 
Coordinate sampler : A non-reversible Gibbs-like sampler
Coordinate sampler : A non-reversible Gibbs-like samplerCoordinate sampler : A non-reversible Gibbs-like sampler
Coordinate sampler : A non-reversible Gibbs-like samplerChristian Robert
 
Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Christian Robert
 
Likelihood-free Design: a discussion
Likelihood-free Design: a discussionLikelihood-free Design: a discussion
Likelihood-free Design: a discussionChristian Robert
 

Mais de Christian Robert (20)

Asymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de FranceAsymptotics of ABC, lecture, Collège de France
Asymptotics of ABC, lecture, Collège de France
 
Workshop in honour of Don Poskitt and Gael Martin
Workshop in honour of Don Poskitt and Gael MartinWorkshop in honour of Don Poskitt and Gael Martin
Workshop in honour of Don Poskitt and Gael Martin
 
discussion of ICML23.pdf
discussion of ICML23.pdfdiscussion of ICML23.pdf
discussion of ICML23.pdf
 
How many components in a mixture?
How many components in a mixture?How many components in a mixture?
How many components in a mixture?
 
restore.pdf
restore.pdfrestore.pdf
restore.pdf
 
Testing for mixtures at BNP 13
Testing for mixtures at BNP 13Testing for mixtures at BNP 13
Testing for mixtures at BNP 13
 
Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?
 
CDT 22 slides.pdf
CDT 22 slides.pdfCDT 22 slides.pdf
CDT 22 slides.pdf
 
Testing for mixtures by seeking components
Testing for mixtures by seeking componentsTesting for mixtures by seeking components
Testing for mixtures by seeking components
 
discussion on Bayesian restricted likelihood
discussion on Bayesian restricted likelihooddiscussion on Bayesian restricted likelihood
discussion on Bayesian restricted likelihood
 
NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)NCE, GANs & VAEs (and maybe BAC)
NCE, GANs & VAEs (and maybe BAC)
 
ABC-Gibbs
ABC-GibbsABC-Gibbs
ABC-Gibbs
 
Coordinate sampler : A non-reversible Gibbs-like sampler
Coordinate sampler : A non-reversible Gibbs-like samplerCoordinate sampler : A non-reversible Gibbs-like sampler
Coordinate sampler : A non-reversible Gibbs-like sampler
 
eugenics and statistics
eugenics and statisticseugenics and statistics
eugenics and statistics
 
Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Laplace's Demon: seminar #1
Laplace's Demon: seminar #1
 
ABC-Gibbs
ABC-GibbsABC-Gibbs
ABC-Gibbs
 
asymptotics of ABC
asymptotics of ABCasymptotics of ABC
asymptotics of ABC
 
ABC-Gibbs
ABC-GibbsABC-Gibbs
ABC-Gibbs
 
Likelihood-free Design: a discussion
Likelihood-free Design: a discussionLikelihood-free Design: a discussion
Likelihood-free Design: a discussion
 
the ABC of ABC
the ABC of ABCthe ABC of ABC
the ABC of ABC
 

Último

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 

Último (20)

Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

Buffon's needle exercises

  • 1. Buffon’s needle(s) 1. Write an R function called dart(n,t,l) that (a) throws uniformly n points (x, y) inside the square [−1, 1] × [−1, 1] and (b) returns the proportion of points within the unit circle, x2 + y 2 ≤ 1. Use dart to derive an approximation of the constant π by this experiment and plot the evolutions of the approximation when the number n of dots grows from 10 to 105 . Buffon’s needle is one of the earliest instances of using simulation to approximate an integral. It uses random throws of needles of length over a wooden floor made of planks of width t ≥ and derives the constant π from the proportion of needles crossing a plank separation (or line). This model assumes all planks are identical, horizontal, and parallel. 2. If we assume that the centre of the needle falls between two lines with uniform probability, show (or use the fact) that the probability that this centre stands within a distance /2 of the closest line is /t. 3. Conditioning on the event that the centre of the needle is within /2 of the closest line of the plank and assuming that the needle is oriented uniformly over (0, π) with respect to the axis of the line, show (or use the fact) that the probability that the needle crosses the closest line is 2/π. 4. Conclude that the overall probability that the needle crosses the closest line is 2 /tπ. 5. If A and B are the coordinates of the extremities of a random needle, show that it crosses a line if and only if the boolean (trunc(A[,2]) != trunc(B[,2])) is true. 6. Write an R code buffon(l,t,n) that approximate this probability by throwing n centres uniformly at random over the [−10t, 10t] × [−10t, 10t] unit square (which contains 19 lines), then generating the angles of the n needles of length l wrt the line uniformly over (0, π) and counting how many needles cross a line. Run this code for n = 105 needles and check whether or not π belongs to the Monte Carlo confidence interval. 7. Expand your R code buffon(l,t,n) to plot the plank separations and the random needles on top of those. 8. Implement the following R code : BuffonsNeedle <- function(n=100, sd=2){ #(C.) Allan Roberts, 2013. X <- rnorm(n,5,sd) Y <- rnorm(n,5,sd) Angle <- runif(n,0,2*pi) X2 <- X + cos(Angle) Y2 <- Y + sin(Angle) CrossesLine <- ( floor(Y) != floor(Y2) ) p <- sum(CrossesLine)/n return(c(p,2/p)) } (a) Explain why (or accept the fact that) this R code is only an approximation to Buffon’s problem. 1
  • 2. (b) Identify from the R code what the corresponding values of and t are. (c) For n = 105 , give a confidence interval on π and check whether π belongs to this interval. (d) Repeat the above verification with sd=0.2, then with sd=.002. 0.1 More Buffon’s needles 1. If X, Y are normal N (0, 1) rv’s, show (or use the fact) that the probability that X 2 +Y 2 ≤ 1 is equal to √ P(X 2 + Y 2 ≤ 1) = 1 − 1/ e 2. Write an R function called hitin(n) that (a) throws n points (x, y) from the standard bivariate normal distribution N2 (0, I) and (b) returns the proportion of points within the unit circle x2 + y 2 ≤ 1. Use hitin to derive an approximation of the constant e by this experiment and plot the evolution of the approximation when the number n of dots grows √ from 10 to 106 . Provide a confidence interval that has a 95% probability to contain 1/ e. 3. We now consider Buffon’s needle experiment, where metal needles of length are thrown upon a wooden floor made of planks of width t ≥ and where the number of times the needles cross a plank separation (or line) is counted. The resulting proportion leads to an approximation of π. (This model assumes all planks are identical, parallel, and horizontal.) (a) We assume that the centre of the needle falls uniformly over a large room, meaning that the second component is uniform over [−D × t, D × t], where 1 D. And that the orientation of the needle is uniform over (0, π). In that case, show (or use the fact) that the probability of crossing a line is line is 2 /tπ. (b) If A and B are the coordinates of the extremities of a random needle, show that it crosses a line if and only if the boolean (trunc(A[,2]) != trunc(B[,2])) takes the value TRUE. (c) Write an R code buffon(l,t,n,D) that approximate this probability by throwing n centres uniformly at random over the [−D × t, D × t] × [−D × t, D × t] unit square (which contains 2D1 lines), then generating the angles of the n needles wrt the line uniformly over (0, π) and counting how many needles cross a line. (d) Study the evolution of the approximation of π as n = 104 and as D decreases from D = 100 to D = 3 by plotting several independent approximations for each value of D you consider. (e) Expand your R code buffon(l,t,n,D) to plot the lines and the random needles. 4. Implement the following R code : BuffonsNeedle <- function(N=1000,D=50,L=.25){ # warning: L is the half-length numbhits <- function(A,B){ sum(abs(trunc(A[,2])-trunc(B[,2]))>0)} O <- runif(N,min=0,max=pi/2) #angle U <- L+runif(N)*(D*sqrt(1+apply(cbind(sin(O)^2,cos(O)^2),1,min))-2*L) C <- cbind(U*cos(O),U*sin(O)) # centre 2
  • 3. A <- C+L*cbind(cos(O),sin(O)) # endpoint A B <- C-L*cbind(cos(O),sin(O)) # endpoint B return(2*2*L*N/numbhits(A,B)) } (a) Explain why this R code is only approximately solving Buffon’s original problem and identify from the R code what the corresponding values of and t are. (b) Study how the corresponding approximation of π converges with N . (c) Repeat the study with D=100, then with D=10. 3