Quiz solutions for Math 103 Probability: Week 11

  1. 1.

    Events (B)

    (i) False. Let Ω={1,2,3}, A={1}, B={2}.

    A and B are exclusive since {1}{2}= but Ac={2,3} and Bc={1,3} are not exclusive since {2,3}{1,3}={3}.

    (ii) False. Let A, B be as above. Then AB={1}, but BA={2}.

    (iii) True

    missingAcBcBAAB=ABc
  2. 2.

    Vets (C)
    (i) violates axiom 2, (ii) is OK, (iii) violates axiom 1.

  3. 3.

    Conditional probabilities (A)

    (a) TRUE. P(A|B)=P(AB)P(B)=0. Since P(AB)=0 as A and B are exclusive events.

    (b) TRUE. If AB then AB=A. So P(A|B)=P(AB)/P(B)=P(A)/P(B).

    (c) TRUE. If AB then AB=A. P(B|A)=P(AB)/P(A)=P(A)/P(A)=1.

  4. 4.

    Vectorised command (B)

    The code finds the maximum of each pair of elements from two vectors of the same length. For example:

    x <- c(1,2,3,4,5)

    y <- c(2,3,2,3,2)

    m <- rep(0,length(x))

    for (i in 1:length(x)) {

    m[i] <- max(x[i],y[i])

    }

    m

    2 3 3 4 5

    The same effect is given by the code in (B). (x >= y) returns a vector which is TRUE(=1) when the element of x is greater than the corresponding element of y and FALSE(=0) otherwise. So x*(x>=y) is a vector whose ith value is x[i] if x[i]>=y[i] and 0 otherwise. By a similar argument y*(x<y) is a vector whose ith value is y[i] if x[i]<y[i] and 0 otherwise. The result follows.

    Note that one might expect the code in (A) to give this result. However it returns a scalar rather than a vector, returning the maximum element of the concatenated vector c(x,y).

  5. 5.

    Recursion relationship II (A) The code should be modified to something like

    inhom_recursion <- function(A,B,k,u,v,N) {

    x <- c(u,v,rep( 1, N -2))

    for( n in 3:N){

    x[n] <- A*x[n-1] + B*x[n-2] + k

    }

    return(x)

    }

    We can then try out the different values of k as follows:

    inhom_recursion(1.5,-1,0.3319,1,1/2,100)[100]

    -1.984991e-05

    inhom_recursion(1.5,-1,-0.1323,1,1/2,100)[100]

    -1.407286

    inhom_recursion(1.5,-1,1.006,1,1/2,100)[100]

    2.043578

    inhom_recursion(1.5,-1,-1.006,1,1/2,100)[100]

    -4.05599

    inhom_recursion(1.5,-1,0.4561,1,1/2,100)[100]

    0.3765042

    Hence the answer is A