Question: Consider the following R function mysomething = function ( n ) { u = runif ( n , 0 , 1 ) x = 0

Consider the following R function
mysomething = function(n){
u = runif(n,0,1)
x =0*u
for(k in 1:n){
if(u[k]<1/2){x[k]=1}
else if(u[k]<3/4){x[k]=2}
else if(u[k]<7/8){x[k]=3}
else if(u[k]<15/16){x[k]=4}
else if(u[k]<31/32){x[k]=5}
else if(u[k]<=1){x[k]=6}}
return(x)}
From what distribution does mysomething draw n samples from? Be as specific as possible.
To receive full credit, write down the set of outcomes and corresponding probabilities of this
distribution.
x 123456
P(X = x)1/21/41/81/161/321/32

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!