(EViews 9) A histogram of two normal random variables

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

question480
Posts: 1
Joined: Thu Oct 22, 2015 1:29 pm

(EViews 9) A histogram of two normal random variables

Postby question480 » Thu Oct 22, 2015 1:58 pm

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.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

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

Postby EViews Glenn » Thu Oct 22, 2015 2:28 pm

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)


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests