Page 1 of 1

(EViews 9) A histogram of two normal random variables

Posted: Thu Oct 22, 2015 1:58 pm
by question480
I am new to the software and was directed to this forum whilst searching for help. I was wondering if anyone could help me?

Let's say that I want to generate a random sample of n observations from a distribution where X is a random variable which takes on Y1 with probability a and Y2 with probability b, where p(a)+p(b)=1.

In addition to this, both Y1 and Y2 are normally distributed. For instance, Y1~ N(3,1/5) and Y2 ~ N(2,1/4).

Could anyone tell me how I could go about doing this?


Thanks.

Re: (EViews 9) A histogram of two normal random variables

Posted: Thu Oct 22, 2015 2:28 pm
by EViews Glenn

Code: Select all

series y1 = @nrnd*@sqrt(1/5)+3 series y2 = @nrnd*@sqrt(1/4)+2 series select = @rnd<.7 series x = y1*select + y2*(1-select)