SlideShare uma empresa Scribd logo
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

Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloChristian 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)

Adaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte CarloAdaptive Restore algorithm & importance Monte Carlo
Adaptive Restore algorithm & importance Monte Carlo
 
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
 

Último

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345beazzy04
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17Celine George
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfbu07226
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePedroFerreira53928
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointELaRue0
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersPedroFerreira53928
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...Nguyen Thanh Tu Collection
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxJenilouCasareno
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxricssacare
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxheathfieldcps1
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online PresentationGDSCYCCE
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxShibin Azad
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasiemaillard
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportAvinash Rai
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesRased Khan
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
 

Último (20)

Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17How to the fix Attribute Error in odoo 17
How to the fix Attribute Error in odoo 17
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
B.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdfB.ed spl. HI pdusu exam paper-2023-24.pdf
B.ed spl. HI pdusu exam paper-2023-24.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 

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