In: Statistics and Probability
I want to use R markdown to do the following questions and render a pdf for all the answers!!!
Q1.
Suppose we toss 4 coins (each having heads probability = (1/2). Let X denote the random variable: (number of heads) - (number of tails).
(a) What is the range of X? (give exact upper and lower bounds along with a line of explanation)
(b) What is the probability mass function of
(c) What is the cumulative density function of X
Q2. Using R, simulate tossing 4 coins as above, and compute the random variable X defined in problem 1. Estimate the probability mass function you computed in part (b) of problem 1 by simulating 1000 times and averaging.
X = Number of heads - number of tails
If we toss 4 coins, then possible number of heads we can get : 0,1,2,3,4
Similarly, possible number of tails we can get : 0,1,2,3,4
Then the random variable can take the values :
-4,-2,0,2,4
(The values listed above are calculated in the following way:
if we get 4 tails and no heads, then X = 0-4 = -4 , if we get 3 tails and 1 head, X = 1-3 = -2 , 2 heads and 2 tails gives us X = 2- 2 =0 and so on)
Hence, upper bound of X is 4 (when we get 4 heads and no tails) and lower bound is -4 (when we get 4 tails and no heads)
Hence range of the random variable X is (Upper bound - Lower bound) = (4 - (-4) ) = 8
b)
X can take value -4 when all the outcomes are tail , and probability of this event is
= 0.0625
X can take value +4 when all the outcomes are head, probability of this event is
=0.0625 ( as we are considering an unbiased coin where probability of getting a head and probability of getting a tail is same and is 0.5)
Now , X can take value -2 when there are 3 tails and 1 head. Here we can consider a binomial distribution with n=4 and probability of success = 0.5 where success is considered as getting a head when a coin is flipped.
Hence, we know the pmf of a binomial distribution with n= 4 and p = 0.5 is
Hence for this event, our required probability is
= 0.25
where the random variable Y denotes the number of heads.
also,
random variable X takes the value 0 when we get 2 heads and 2 tail and probability of this event is
Again, random variable X takes the value 2 when there are 3 heads and 1 tail and probability of this event is
Hence, the probability distribution of the random variable X is given by
Cumulative Density Function of X