Thursday, April 16, 2009

Planting trees in Southern California

Climate note about Southern California

The Southern California coast extends from San Diego to San Luis Obispo and includes Santa Barbara, Ventura, western portions of Los Angeles County and Orange County and San Diego.

The Southern California coast is influenced by the Pacific Ocean and has a mild climate due to the marine air. Summers are moderate in temperature and coastal fog is common. Hot, dry winds, known as 'Santa Ana’s' can be damaging here and in the inland areas of Southern California. Inland Southern California includes Riverside, San Bernardino, Pasadena, Glendale, Burbank, the San Fernando Valley, Ojai Valley, and Santa Paula. The interior is more subject to hot, dry desert air than the coast and is considerably warmer.

Annual rainfall along the northern coast can be as high as 16 inches in Santa Barbara and as low as 9 inches in San Diego. Droughts are not uncommon, and all crops are irrigated. The main temperate fruit and nut crops grown commercially in this region are apple, macadamia, olive, peach, persimmon, and English walnut. Since winters along the Southern California coast and interior are usually mild and often frost-free, temperate tree fruit varieties with low winter chill requirements are usually chosen because the low latitudes in this region receives a more limited number of total hours (100~400) at 45ºF, which are necessary to mature fruit, than other regions in the state.

Monday, April 06, 2009

Coins with random bias

Suppose you are given a coin with random bias. The bias of the coin is uniformly distributed over [0, 1] and assume that the value of the bias does not change during the tosses.
(a) What is the probability that all three tosses are heads?
(b) What is the probability that the second toss is Head when the first toss turns out as Head?

Solution:
Let Xi, i=1, 2,3, denote the outcome of the i-th coin toss, then:

So the probability of three heads is 1/4.


So the probability of second toss being H when the first one turns out as H is 2/3.

Thursday, April 02, 2009

How many tosses to get 2 heads

Question: Given a fair coin, how many tosses on average do you need to get 2 heads?

Heuristic based solution:

This is based on the general principle of conditional averages and dependency/independence between events.

Suppose
E(x) = average tosses needed to have 2 heads
E(x|H) = average total tosses needed to have 2 Heads when the first toss is Head
E(x|T) = average total tosses needed to have 2 Heads when the first toss is Tail
E(x|HH) =average total tosses needed to have 2 Heads when the first two tosses are heads = 2
E(x|HT) = average total tosses needed to have 2 Heads when the first two tosses are HT
Then we have the following relationships:
E(x|T) = 1 + E(x) (The first toss is wasted so we are back to nothing)
E(x|HT) = 2 + E(x) (The first two tosses are wasted and we are back to square 1)
Further, we have the following relationship:
E(X) = 0.5 E(x|H) + 0.5 E(x|T)
= 0.5 { 0.5 E(x|HH) + 0.5 E(x|HT)} + 0.5 (1 + E(x))
= 0.5 { 0.5*2 + 0.5 [2 + E(x)]} + 0.5 + 0.5 E(x)
= 1 .5 + 0.75 E(x)
Solving the equation, we get E(x) = 6, meaning on average 6 tosses are needed to get 2 heads.

If the question is for 3 or more consecutive patterns, similar approach can be used. But the number of iteration needed will be more than the two levels we show here.

Markov chain based solution:




As shown in the above figure, define a Markov chain that is formed by the following three states:
S1: the previous tossing generates Tail ;
S2: the previous tossing generates Head;
S3: after current tossing, we get two consecutive Hs.



Then, the probability transition matrix, denoted by P, is represented in the first equation above.

It can also be seen that S3 is an absorbing state. What we need to calculate is the average steps need to reach the absorbing state. We use hi to denote the average number tosses needed to move from state Si to S3 (also known as average hitting time). Clearly, we have h3 = 0. Then, we have the second equation shown above.

Basically, this is based also on the principle of conditional expectation also. The left side is a decomposition of the first toss and what happens after the first toss.
Solving this equation, we get h1 = 6; h2 = 4.
Then the expected number X of tosses to get two heads in a row is given by the third equation above, meaning on average 6 tosses are needed to get 2 consecutive heads.

The same method can be generalized to calculate the average number of tosses to get N heads in a row. The states in the Markov chain will be all the initial sequence of the final N heads. For example, N=3 means the following state (H, T, HH, HHH). Another example, if we want to calculate the same for HTH, then the Markov chain is formed by (T, H, HT, HTH).