*10 In Exercise 2.2.12 you proved the following: If you take a stick of unit length and break it into three pieces, choosing the breaks at random (i.e., choosing two real numbers independently and uniformly from [0, 1]), then the probability that the three pieces form a triangle is 1/4. Consider now a similar experiment: First break the stick at random, then break the longer piece at random. Show that the two experiments are actually quite different, as follows:

  1. Write a program which simulates both cases for a run of 1000 trials, prints out the proportion of successes for each run, and repeats this process ten times. (Call a trial a success if the three pieces do form a triangle.) Have your program pick (x, y) at random in the unit square, and in each case use x and y to find the two breaks. For each experiment, have it plot (x, y) if (x, y) gives a success.

  2. Show that in the second experiment the theoretical probability of success is actually 2 log 2 ??? 1.

(Please Also see section 2.2 Exercise 12

12. Take a stick of unit length and break it into three pieces, choosing the break points at random. (The break points are assumed to be chosen simultaneously.) What is the probability that the three pieces can be used to form a triangle? Hint: The sum of the lengths of any two pieces must exceed the length of the third, so each piece must have length < 1/2.)

(a)

#expeiment 1: The two break points are assumed to be chosen simultaneously

# let b1 and b2 be the break points and b1 denote the longer one when measure from 0

#simulation
n <- 1000
set.seed(NULL)
b1 <- runif(n)
set.seed(NULL)
b2 <- runif(n)
p <- rep(0,n)
iv <- 0

for (i in 1:n) {
  if (b1[i]<b2[i]){
    temp <- b1[i]
    b1[i]<- b2[i]
    b2[i] <-temp
  }
  if (b1[i] == b2[i]){
    iv <- iv + 1
  }
  if ((b2[i]<.5) & ((b1[i]-b2[i])<.5) & ((1-b1[i])<.5)) {
    p[i] <- 1
  }
}

cat("Probability:",sum(p)/n)
## Probability: 0.261
#####################
#expeiment 2 :The two break points are assumed to be chosen sequentially

#let b1 be the first break point and b2 be the second break point
n <- 1000
set.seed(NULL)
b1 <- runif(n,0.5,1)
set.seed(NULL)
b2 <- runif(n,0,b1)
p <- rep(0,n)

for (i in 1:n) {
  if ((b2[i]<.5) & ((b1[i]-b2[i])<.5) & ((1-b1[i])<.5)) {
    p[i] <- 1
  }
}
cat("Probability:",sum(p)/n)
## Probability: 0.396

(b)

let b1 be the first break point and b2 be the second break point, then we know b1 > b2

b1 > 0.5

b2 < 0.5

b2 +(1-b1) > b1-b2

so we know

b2 > b1-0.5

the probability of b1-0.5 < b2 < 0.5 is: (0.5-(b1-0.5))/b1 = (1-b1)/b1

\[\begin{equation} \frac{\int_{0}^{5}\frac{1-b1}{b1}}{1-0.5}=2ln(|x|)-1 \end{equation}\]