Question: a ) Using loop in R to evaluate ( approximate ) the expectation of binomial distributed random variables having the following probability mass function. P

a) Using loop in R to evaluate (approximate) the expectation of binomial distributed random variables having the following probability mass function.
P(x=k)=([n],[k])pk(1-p)n-k for k=0,1,2,cdotsn
Compute the expectation using the definition of the expectation of a discrete random variable, not a short cut formula for a binomial random variable. In your approximation, consider n=10,20 and 30 with p=0.25 and 0.6 respectively. Your code should loop through the values of n and p, and for each combination of n and p, it should loop through each value of x in the definition of the expected value. Store your values in a matrix called expected. Do NOT use the built-in function dbinom() for this question.
b) Based on the R code in part (a), create an R function called BinExp that can return the approximated expectation of a binomial distributed random variable with any given n>1 and pin(0,1).
 a) Using loop in R to evaluate (approximate) the expectation of

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!