Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Thx 6. Suppose you have a blue and red parallel striped floor. Each stripe has equal thickness of t units. If you drop a matchstick
Thx
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 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 z S (a) (8 points) Create a function barPi,t,n) that uses the hit-or-miss method and the above for mulation to approximate the value o by simulating dropping many matchsticks onto the floor Assume that St and that >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 returs 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.08.1.0 (keeping t = 1 constant). You will simulate dropping 1000 needles for each experi- ment. What do you notice? Explain. One ne of R code per value, so 3 total lines of code 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 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 z S (a) (8 points) Create a function barPi,t,n) that uses the hit-or-miss method and the above for mulation to approximate the value o by simulating dropping many matchsticks onto the floor Assume that St and that >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 returs 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.08.1.0 (keeping t = 1 constant). You will simulate dropping 1000 needles for each experi- ment. What do you notice? Explain. One ne of R code per value, so 3 total lines of code Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started