Three Interesting Problems: Part 3.

We’re going to continue our work on the “interesting problems” by considering a new model. Suppose that a given event (say, a cosmic ray striking a detector) has a fixed probability of occurring during a given unit of time. What is the distribution of the times between events?

Let’s start by learning a few more functions which will help us collect some data. As before, you should read along with your group in this notebook, executing each piece of code (here) and adding your own cells to include your own work.

We start by learning the RandomChoice function, assuming that there is a 1/30 probability of the event occurring during each measurement period.

RandomChoice[{1/30,29/30}->{True,False}]

This function chooses between alternatives (the list on the right) with different probabilities (the list on the left). We can get a list of many such choices by adding the number of data points we’d like to see.

RandomChoice[{1/30,29/30}->{True,False},100]

We’d like to gather data on the number of trials between each pair of “True”s in the list. We can do that by first finding the locations of the “Trues” with the “Position” function:

Position[RandomChoice[{1/30,29/30}->{True,False},100],True]

Since the Position function gives us a list of lists, and we’d prefer a list of numbers, we can use “Flatten” to reduce things to a list of numbers.

Flatten[Position[RandomChoice[{1/30,29/30}->{True,False},100],True]]

Then we can get the intervals between positions with Differences

Differences[Flatten[Position[RandomChoice[{1/30,29/30}->{True,False},100],True]]
]

and we can plot the distribution of this data with Histogram like we did before. Here, instead of giving a specific number of bins like we did previously, we’ll use “Wand” binning, which makes a pretty good choice based on the data.

Histogram[
Differences[
Flatten[
Position[RandomChoice[{1/30,29/30}->{True,False},10000000],True]
]
],
"Wand","PDF"
]

We can also get the CDF of our data:

Histogram[
Differences[
Flatten[
Position[RandomChoice[{1/30,29/30}->{True,False},10000000],True]
]
],
"Wand","CDF"
]

Work for your group.

In the cells below, generate several different PDF and CDF plots for different values of the probability λ of the event occurring in each measurement interval.

Theory

We are now going to introduce a new idea:

Definition. Two events E and F are independent if P(E ∧ F) = P(E) · P(F).

We will give various interpretations of independence as we go forward, but for now, let’s just take the definition on faith.

Suppose that X(λ) is a random variable given by the length between failures where the probability of failure occurring during the interval of time (a,b) is:

	1) proportional to length(a,b), 
	2) equal to λ when length(a,b) = 1,
	3) and the events “Failure in (a,b)” and “Failure in (c,d)” are independent when (a,b) and (c,d) 	are disjoint intervals.

Work for your group

Exercise. Prove that if E, F are independent events, then ¬E and ¬F are also independent events.

Please write down your proof in the cells below this one (or on paper-- you can take a picture and drag and drop it into a Mathematica notebook cell).

Back to theory.

We are now going to think about the form of the cdf (Subscript[F, X])(t) of X. To do that, we’re going to another

Definition. The survival function of a continuous random variable X is given by 

	(Subscript[S, X])(t) = P({X > t}) = 1 - (Subscript[F, X])(t)

Imagine that time t has passed between failures. This is the event “no failure in (0,t)”, which occurs with probability (Subscript[S, X])(t).

During the next interval of time (t,t+h), the probability of failure is λ h, which means that the probability of avoiding failure is 1 - λ h. Now we can compute

(Subscript[S, X])(t+h) = P("no failure in (0,t+h)") 
                     = P("no failure in (0,t)") · P("no failure in (t,t+h)")
                     = (Subscript[S, X])(t) (1 - λ h)

We can now write

(Subscript[S, X])(t+h) - (Subscript[S, x])(t) = (Subscript[S, X])(t)(1 - λh) - (Subscript[S, X])(t) = -λ h (Subscript[S, X])(t)

and use this to compute the derivative

(d/dt)(Subscript[S, X])(t) = (lim_(h -> 0))(((Subscript[S, X])(t+h) - (Subscript[S, x])(t))/h)=-λ (Subscript[S, X])(t)

Work for your group.

Now it’s time to remember the techniques you learned to solve differential equations in MATH 2700. You need to solve the differential equation (Subscript[S, X])'(t) = -λ (Subscript[S, X])(t) for (Subscript[S, X])(t), using the boundary condition (Subscript[S, X])(0) = 1. The notation might look a little bit weird, but this is the differential equation:

	f'(x) = k f(x), f(0) = 1

which you have solved before. In the cells immediately below this one, write down your solution to the differential equation and check to make sure that obeys the boundary conditions. You can do this by hand or with Mathematica’s DSolve command.

Once you have solved the differential equation for (Subscript[S, X])(t), use the expressions

	(Subscript[S, X])(t) = 1 - (Subscript[F, X])(t)   and (Subscript[μ, X])(t) = (Subscript[F, X])'(t)

to find (Subscript[F, X])(t) and (Subscript[μ, X])(t). Write down your work in the cells immediately below this one.

Combining Theory and Practice - Work for your group

Use the Show command to plot your CDFs and PDFs for X(λ) together with the experimental PDF and CDFs you derived above for different values of λ. Make sure that they match! If they don’t, one of the two computations is wrong and you should find the problem and fix it.

Do this in the cells below, and include some explanation.

Bonus: You can make a histogram of the survival function by replacing “PDF” or “CDF” with “SF”. Use the Show command to display your survival function atop the experimental survival function and make sure they match.