Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6. Suppose you have a blue and red parallel striped floor. Each stripe has equal thickness of t units. If you drop a matchstick of

image text in transcribed

6. Suppose you have a blue and red parallel striped floor. Each stripe has equal thickness of t units. If you drop a matchstick of length l on the floor, the probability that it will cross the border between two stripes can be computed as P =. Note, if x is the center of the needle to the closest line and the acute angle between the needle and the lines, then it can be shown analytically that a needle will cross a line if x s (sine (a) (8 points) Create a function barPi (e,t,n) that uses the hit-or-miss method and the above for mulation to approximate the value of by simulating dropping many matchsticks onto the floor Assume that S t and that n > 0 is the number of sampleseedles to drop. Be sure that your code checks that the parameters are appropriate and gives useful error messages, as well as return a value of 0 if no needle crosses a line (your calculation returns Inf)! The complete function needs no more than 4 lines of R code. (b) (2 points) Create a function to return the mean and standard deviation of a vector of values. Only 1 line of R code (c) (6 points) Compare the mean/standard deviation (using your function from part (c)) for 1 = 0.5, 0.8, 1.0 (keeping t 1 constant). You will simulate dropping 1000 needles for each experi- ment. What do you notice? Explain. One line of R code per value, so 3 total lines of code needed. 6. Suppose you have a blue and red parallel striped floor. Each stripe has equal thickness of t units. If you drop a matchstick of length l on the floor, the probability that it will cross the border between two stripes can be computed as P =. Note, if x is the center of the needle to the closest line and the acute angle between the needle and the lines, then it can be shown analytically that a needle will cross a line if x s (sine (a) (8 points) Create a function barPi (e,t,n) that uses the hit-or-miss method and the above for mulation to approximate the value of by simulating dropping many matchsticks onto the floor Assume that S t and that n > 0 is the number of sampleseedles to drop. Be sure that your code checks that the parameters are appropriate and gives useful error messages, as well as return a value of 0 if no needle crosses a line (your calculation returns Inf)! The complete function needs no more than 4 lines of R code. (b) (2 points) Create a function to return the mean and standard deviation of a vector of values. Only 1 line of R code (c) (6 points) Compare the mean/standard deviation (using your function from part (c)) for 1 = 0.5, 0.8, 1.0 (keeping t 1 constant). You will simulate dropping 1000 needles for each experi- ment. What do you notice? Explain. One line of R code per value, so 3 total lines of code needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago

Question

Explain the Neolithic age compared to the paleolithic age ?

Answered: 1 week ago