Quiz solutions for Math 103 Probability: Week 11
-
1.
Events (B)
(i) False. Let , , .
and are exclusive since but and are not exclusive since .
(ii) False. Let , be as above. Then , but .
(iii) True
-
2.
Vets (C)
(i) violates axiom 2, (ii) is OK, (iii) violates axiom 1. -
3.
Conditional probabilities (A)
(a) TRUE. . Since as and are exclusive events.
(b) TRUE. If then . So .
(c) TRUE. If then . .
-
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.
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 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