Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Gaussian Mixture
Date: Wed, 25 Mar 2009 17:41:01 +0000 (UTC)
Organization: Xoran Technologies
Lines: 42
Message-ID: <gqdqbd$44c$1@fred.mathworks.com>
References: <gqc6nk$h5n$1@fred.mathworks.com> <gqdc34$go5$1@fred.mathworks.com> <gqdddi$mfe$1@fred.mathworks.com> <gqdh51$qju$1@fred.mathworks.com> <gqdlk1$l78$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1238002861 4236 172.30.248.38 (25 Mar 2009 17:41:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Wed, 25 Mar 2009 17:41:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1440443
Xref: news.mathworks.com comp.soft-sys.matlab:527683


"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
> > > &#8226; Generate the two normal pdfs with function normpdf, just as previously. Plot the pdfs into
> > > a single figure.
> > > &#8226; Calculate the weighted sum of these two pdfs, which is the GM-pdf. Plot the GM-pdf with
> > > the function plot &#8211; 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