Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: convolve 2 probability distributions
Date: Mon, 30 Jun 2008 14:34:02 +0000 (UTC)
Organization: SwissRe
Lines: 41
Message-ID: <g4aqsq$gar$1@fred.mathworks.com>
References: <g3ra0s$g8k$1@fred.mathworks.com> <g3tg6p$cdg$1@z-news.pwr.wroc.pl>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1214836442 16731 172.30.248.37 (30 Jun 2008 14:34:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 30 Jun 2008 14:34:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1231417
Xref: news.mathworks.com comp.soft-sys.matlab:476631



pisz_na.mirek@dionizos.zind.ikem.pwr.wroc.pl wrote in 
message <g3tg6p$cdg$1@z-news.pwr.wroc.pl>...
> Patrice Tscherrig <patrice.tscherrig@gmx.ch> wrote:
> > Hi  - probably an easy one: 
> > 
> > How do I nummerically convolve 2 probability 
distributions
> > and see the resulting distribution? 
> > P = [(0+eps):0.01:(1-eps)];
> > normint = norminv(P,0.05,0.005)
> > lognint = logninv(P,log(0.05),3);
> > X = lognpdf(lognint,log(0.05),3);
> > Y = normpdf(normint,0.05,0.005);
> > total = conv(X,Y);
> > figure,hist(total)
> 
> 1) conv works on equidistant points
> 2) if you have pdf dont use hist but plot
> 
> You need do it like this:
> 
> x=(-1:.001:1);
> l=lognpdf(x,log(0.05),3);
> n=normpdf(x,0.05,0.005);
> ln=conv(l,n)*(x(2)-x(1));
> plot( x,n, x,l, x*2,ln(1:2:end) );
> xlim([.0,.3]);ylim([0,100]);
> 
> 
Hi

Thanks for the hint - very useful! could you however 
elaborate on why to use: 
 x*2
and 
ln(1:2:end)
? 

regards, 

Patrice