首页 > > 详细

辅导EE020辅导留学生Matlab设计

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

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!