辅导案例-EE020

  • June 3, 2020

Name: SID#: Quiz EE020 Instructor: Dr. Cheng TA: Sajjad Bahrami In MATLAB, normrnd(mu,sigma) generates a random number from the Gaussian dis- tribution with mean parameter mu and standard deviation parameter sigma. Furthermore, binornd(n,p) generates random numbers from the binomial distribution specified by the number of trials n and the probability of success for each trial p. In this quiz, we want to use these two MATLAB internal functions to generate ran- dom numbers generated with probability p from N (µ1, σ21) and with probability 1-p from N (µ2, σ22) (Note: N (µ, σ2) denotes a Gaussian distribution with mean µ and variance σ2). 1. Write a function MGRN(mu1,sigma1,mu2,sigma2,i,p) in MATLAB which takes means and standard deviations of two Gaussian distributions as µ1, µ2 and σ1, σ2, respectively and generates i random numbers generated with probability p from distribution 1 and with probability 1− p from distribution 2. (Hint: you can use binornd(1,p)*normrnd(mu1,sigma1) to generate a number from distribution 1 with probability p) 2. Set mu1=0,mu2=5,sigma1=sigma2=1,i=10000,p=0.3 and call your function to gener- ate 10000 random numbers generated with probability p=0.3 from distribution 1 and with probability 1-p=0.7 from distribution 2. Store these numbers in vector x. Use hist(x,100) to create a histogram bar by putting numbers of vector x into 100 equally spaced bins. Show me your function file and histogram during discussion. Good Luck

LATEST POSTS
MOST POPULAR

ezAce多年来为广大留学生提供定制写作、留学文书定制、语法润色以及网课代修等服务,超过200位指导老师为您提供24小时不间断地服务。