SlideShare ist ein Scribd-Unternehmen logo
1 von 3
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...KokoStevan
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
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
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.MateoGardella
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfSanaAli374401
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
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.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
An Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdfAn Overview of Mutual Funds Bcom Project.pdf
An Overview of Mutual Funds Bcom Project.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).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