|
"Jose Valerio" <lapenda@gmail.com> wrote in message <gqdlk1$l78$1@fred.mathworks.com>...
> "Matt " <xys@whatever.com> wrote in message <gqdh51$qju$1@fred.mathworks.com>...
> > "Jose Valerio" <lapenda@gmail.com> wrote in message <gqdddi$mfe$1@fred.mathworks.com>...
> > > Peter Perkins <Peter.Perkins@MathRemoveThisWorks.com> wrote in message <gqdc34$go5$1@fred.mathworks.com>...
> > > > Jose Valerio wrote:
> > > >
> > > > > I have to generate 1000 samples distributed according to Gaussian Mixture distribution. And it has to consist of the sum of two distribution N(-2,1) and (2,1). weights of 0.4 and 0.6
> > > > >
> > > > > I know that there is a method to generate the random numbers based on the inverse function of the cdf of that distribution and that's what I need to use, but I just can't figure it out.
> > > >
> > > > You _can_ do that if that's what the homework assignment asks for, but there's a more obvious way. Consider what a mixture model is: a random value chosen from one of two probability distributions with (in your case) probabilities .4 and .6. If that sounds like a constructive definition useful for generating a random value from the mixture, it is.
> > > >
> > > > Hope this helps.
> > >
> > > Ok, this is the whole asignment, but I can't find anything on my lectures that can help much with it. I've tried different ways and I still don't get it, maybe if it was worded a different way I would have a better chance of completing it.
> > >
> > > A method to generate random numbers from any distribution is based on the inverse function of
> > > the cdf of that distribution (see the below figure to understand the principle of the method).
> > > Use the method to generate 1000 samples distributed according to a Gaussian Mixture -
> > > distribution (GM), which consist of the weighted sum of two normal distributions N(-2,1) and
> > > N(2,1), with the corresponding weights of 0.4 and 0.6.
> > > Application For Data Analysis - 2 -
> > > Final Project Winter 2009
> > > • Generate the two normal pdfs with function normpdf, just as previously. Plot the pdfs into
> > > a single figure.
> > > • Calculate the weighted sum of these two pdfs, which is the GM-pdf. Plot the GM-pdf with
> > > the function plot – does it look like the weighted sum of two normal distributions?
> >
> >
> > A hint. You can do this with a combination of erf() and interp1()
>
> i have to use normpdf().
I think you mean normcdf(). The instructions you posted are all about CDF's
> So what I did was,
> x=-50:0.1:50 %These are my 1000 samples, or I could just do ramdom numbers
> y=normpdf(x,-2,1); %This is normal distributions N(-2,1)??? Here is where I'm a little confuse. What does the N(-2,1) means?? is it a range od the mean -2 and Variace 1???
> plot(x,y)
N(-2,1) means a Gaussian distribution with mean -2 and variance 1
|