⧼exchistory⧽
11 exercise(s) shown, 0 hidden
BBy Bot
Jun 09'24

In the spinner problem (see Example) divide the unit circumference into three arcs of length 1/2, 1/3, and 1/6. Write a program to simulate the spinner experiment 1000 times and print out what fraction of the outcomes fall in each of the three arcs. Now plot a bar graph whose bars have width 1/2, 1/3, and 1/6, and areas equal to the corresponding fractions as determined by your simulation. Show that the heights of the bars are all nearly the same.

BBy Bot
Jun 09'24

Do the same as in Exercise, but divide the unit circumference into five arcs of length 1/3, 1/4, 1/5, 1/6, and 1/20.

BBy Bot
Jun 09'24

Alter the program MonteCarlo to estimate the area of the circle of radius 1/2 with center at [math](1/2,1/2)[/math] inside the unit square by choosing 1000 points at random. Compare your results with the true value of [math]\pi/4[/math]. Use your results to estimate the value of [math]\pi[/math]. How accurate is your estimate?

BBy Bot
Jun 09'24

Alter the program MonteCarlo to estimate the area under the graph of [math]y = \sin\pi x[/math] inside the unit square by choosing 10,00 points at random. Now calculate the true value of this area and use your results to estimate the value of [math]\pi[/math]. How accurate is your estimate?

BBy Bot
Jun 09'24

Alter the program MonteCarlo to estimate the area under the graph of [math]y = 1/(x + 1)[/math] in the unit square in the same way as in Exercise. Calculate the true value of this area and use your simulation results to estimate the value of [math]\log 2[/math]. How accurate is your estimate?

BBy Bot
Jun 09'24

To simulate the Buffon's needle problem we choose independently the distance [math]d[/math] and the angle [math]\theta[/math] at random, with [math]0 \leq d \leq 1/2[/math] and [math]0 \leq \theta \leq \pi/2[/math], and check whether [math]d \leq (1/2)\sin\theta[/math]. Doing this a large number of times, we estimate [math]\pi[/math] as [math]2/a[/math], where [math]a[/math] is the fraction of the times that [math]d \leq (1/2)\sin\theta[/math]. Write a program to estimate [math]\pi[/math] by this method. Run your program several times for each of 100, 1000, and 10,00 experiments. Does the accuracy of the experimental approximation for [math]\pi[/math] improve as the number of experiments increases?

BBy Bot
Jun 09'24
[math] \newcommand{\NA}{{\rm NA}} \newcommand{\mat}[1]{{\bf#1}} \newcommand{\exref}[1]{\ref{##1}} \newcommand{\secstoprocess}{\all} \newcommand{\NA}{{\rm NA}} \newcommand{\mathds}{\mathbb}[/math]

For Buffon's needle problem, Laplace[Notes 1] considered a grid with horizontal and vertical lines one unit apart. He

showed that the probability that a needle of length [math]L \leq 1[/math] crosses at least one line is

[[math]] p = \frac{4L - L^2}\pi\ . [[/math]]

To simulate this experiment we choose at random an angle [math]\theta[/math] between 0 and [math]\pi/2[/math] and independently two numbers [math]d_1[/math] and [math]d_2[/math] between 0 and [math]L/2[/math]. (The two numbers represent the distance from the center of the needle to the nearest horizontal and vertical line.) The needle crosses a line if either [math]d_1 \leq (L/2)\sin\theta[/math] or [math]d_2 \leq (L/2)\cos\theta[/math]. We do this a large number of times and estimate [math]\pi[/math] as

[[math]] \bar \pi = \frac{4L - L^2}a\ , [[/math]]

where [math]a[/math] is the proportion of times that the needle crosses at least one line. Write a program to estimate [math]\pi[/math] by this method, run your program for 100, 1000, and 10,00 experiments, and compare your results with Buffon's method described in Exercise Exercise. (Take [math]L = 1[/math].)

Notes

  1. P. S. Laplace, Théorie Analytique des Probabilités (Paris: Courcier, 1812).
BBy Bot
Jun 09'24

A long needle of length [math]L[/math] much bigger than 1 is dropped on a grid with horizontal and vertical lines one unit apart. We will see (in Exercise) that the average number [math]a[/math] of lines crossed is approximately

[[math]] a = \frac{4L}\pi\ . [[/math]]

To estimate [math]\pi[/math] by simulation, pick an angle [math]\theta[/math] at random between 0 and [math]\pi/2[/math] and compute [math]L\sin\theta + L\cos\theta[/math]. This may be used for the number of lines crossed. Repeat this many times and estimate [math]\pi[/math] by

[[math]] \bar \pi = \frac{4L}a\ , [[/math]]

where [math]a[/math] is the average number of lines crossed per experiment. Write a program to simulate this experiment and run your program for the number of experiments equal to 100, 1000, and 10,00. Compare your results with the methods of Laplace or Buffon for the same number of experiments. (Use [math]L = 100[/math].)

BBy Bot
Jun 09'24

A large number of waiting time problems have an exponential distribution of outcomes. We shall see (in Important Densities) that such outcomes are simulated by computing [math](-1/\lambda)\log(\mbox{rnd})[/math], where [math]\lambda \gt 0[/math]. For waiting times produced in this way, the average waiting time is [math]1/\lambda[/math]. For example, the times spent waiting for a car to pass on a highway, or the times between emissions of particles from a radioactive source, are simulated by a sequence of random numbers, each of which is chosen by computing [math](-1/\lambda)\log(\mbox{rnd})[/math], where [math]1/\lambda[/math] is the average time between cars or emissions. Write a program to simulate the times between cars when the average time between cars is 30 seconds. Have your program compute an area bar graph for these times by breaking the time interval from 0 to 120 into 24 subintervals. On the same pair of axes, plot the function [math]f(x) = (1/30)e^{-(1/30)x}[/math]. Does the function fit the bar graph well?

BBy Bot
Jun 09'24

In Exercise, the distribution came “out of a hat.” In this problem, we will again consider an experiment whose outcomes are not equally likely. We will determine a function [math]f(x)[/math] which can be used to determine the probability of certain events. Let [math]T[/math] be the right triangle in the plane with vertices at the points [math](0, 0),\ (1, 0),[/math] and [math](0,1)[/math]. The experiment consists of picking a point at random in the interior of [math]T[/math], and recording only the [math]x[/math]-coordinate of the point. Thus, the sample space is the set [math][0,1][/math], but the outcomes do not seem to be equally likely. We can simulate this experiment by asking a computer to return two random real numbers in [math][0, 1][/math], and recording the first of these two numbers if their sum is less than 1. Write this program and run it for 10,00 trials. Then make a bar graph of the result, breaking the interval [math][0, 1][/math] into 10 intervals. Compare the bar graph with the function [math]f(x) = 2 - 2 x[/math]. Now show that there is a constant [math]c[/math] such that the height of [math]T[/math] at the [math]x[/math]-coordinate value [math]x[/math] is [math]c[/math] times [math]f(x)[/math] for every [math]x[/math] in [math][0, 1][/math]. Finally, show that

[[math]] \int_0^1 f(x)\,dx = 1\ . [[/math]]

How might one use the function [math]f(x)[/math] to determine the probability that the outcome is between [math].2[/math] and [math].5[/math]?