Question: 2. Use the following MATLAB function to generate a vector called rv consisting of 50000 numbers from the set {-2 -1 0 1 2} with

2. Use the following MATLAB function to generate a vector called rv consisting of 50000 numbers from the set {-2 -1 0 1 2} with the corresponding probability distribution (.25 .2 .1 .2 .25). Create a histogram of the numbers. The command sv=sum(reshape(rv,10,5000)) --> creates a vector sv of 5000 numbers, each computed as a sum of 10 numbers from rv. Create a histogram of the sv values. Compare and comment.

function rr = finited(xx,pp,n) cdf=cumsum(pp) ; rr=[] ; for j= 1:n

 u=rand() ; k=1 ; while (cdf(k) 

k=k+1 ; end

 rr = [rr,xx(k)] ; 

end end

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!