Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!news-fra1.dfn.de!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: pisz_na.mirek@dionizos.zind.ikem.pwr.wroc.pl
Newsgroups: comp.soft-sys.matlab
Subject: Re: convolve 2 probability distributions
Date: Wed, 25 Jun 2008 13:11:53 +0000 (UTC)
Organization: WUT
Lines: 26
Message-ID: <g3tg6p$cdg$1@z-news.pwr.wroc.pl>
References: <g3ra0s$g8k$1@fred.mathworks.com>
NNTP-Posting-Host: infrared.zind.ikem.pwr.wroc.pl
X-Trace: z-news.pwr.wroc.pl 1214399513 12720 156.17.14.223 (25 Jun 2008 13:11:53 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Wed, 25 Jun 2008 13:11:53 +0000 (UTC)
User-Agent: tin/1.9.3-20080506 ("Dalintober") (UNIX) (Linux/2.6.22-3-k7 (i686))
Xref: news.mathworks.com comp.soft-sys.matlab:475771



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]);