Convolution of two independent normally distributed random variables
8 次查看(过去 30 天)
显示 更早的评论
If x and y are independent and both normal with mean=5, and v=4, then z=x+y should be normal with mean=10, and v=8. Why can't I proof this using convolution in Matlab.
a=linspace(-5,15,10000); x=normpdf(a,5,2); y=normpdf(a,5,2); z=conv(x,y); m=mean(z); sd=std(z);
0 个评论
回答(3 个)
Wayne King
2012-9-14
编辑:Wayne King
2012-9-14
Hi, you are confusing things here a bit. You don't want to consider the mean and standard deviations of the PDFs. You want to consider the mean and standard deviation of the random variables. Those are very different things.
x = normrnd(5,2,1000,1);
y = normrnd(5,2,1000,1);
z = x+y;
mean(z), var(z)
To see that the N(0,8) (here I mean variance 8) is good fit to z
x = normrnd(5,2,1000,1);
y = normrnd(5,2,1000,1);
z = x+y;
mu = 10;
sigma = sqrt(8);
zmin = min(z); zmax = max(z); zrange = range(z);
binw = zrange / 30;
edges = zmin + binw*(0:30);
n = histc(z, edges);
bar(edges, n, 'histc');
hold on
xx = zmin:(zrange/1000):zmax;
plot(xx, binw*length(z)*normpdf(xx,mu,sigma), 'r');
title('Normal Fit');
The PDF of z is the convolution of the PDFs of x and y
2 个评论
Rick Rosson
2012-9-14
Please try:
mean(x)
std(x)
What does it show? Is it what you expected? Why or why not?
Likewise:
mean(y)
std(y)
0 个评论
Star Strider
2012-9-14
编辑:Star Strider
2012-9-14
Since the convolution is based on the variables described by a specific distribution, it's likely best to look at the inverse normal distribution:
p = linspace(0.001,0.999,10000);
x = norminv(p,5,2);
y = norminv(p,5,2);
These give the values of a mean of 5 and a standard deviation of 2:
mx = mean(x);
sx = std(x);
my = mean(y);
sy = std(y);
and these give the values of a mean of 10 and standard deviation of 4:
z = x + y;
mz = mean(z);
sz = std(z);
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!