3 views (last 30 days)

This might be a trivial question but i calculated 3 gaussian pdf's on the domain

x = [0 : 0.1 : 200],

and computed the pdf's as:

y1 = normpdf(x,mu1,sigma1)

y2 = normpdf(x,mu2,sigma2)

y3 = normpdf(x,mu3,sigma3)

I averaged them together such that:

y_final = (y1+y2+y3)./3

My question is how can I obtain the the mean and standard deviation of the y_final?

David Goodmanson
on 5 Nov 2020

Hi Matthew,

here is an example, where mu and sigma are calculated by numerical integration. Also shown are analytical results for those, which agree with the numerical results. For the mean of y = (y1 +y2 +y3)/3,

mu = (mu1 + mu2 + mu3)/3

which is not a big surprise. The variance of y is

var = Integral (x-mu)^2*(y1 +y2 +y3)/3 dx

If y1 has mean mu1 and standard deviation sigma1 then the integral involving y1 above is

sigma1^2 + (mu-mu1)^2

and similarly for y2 and y3. The analytic expression for the variance and standard deviation is shown below.

Note that none of these results has anything to do with whether or not the pdfs are normal distributions. The pdfs could be anything, not even of the same type (as long as each is normalized to 1), and the result is the same.

xplot = -20:.001:38; % use plenty of points

figure(1)

plot(xplot,y(xplot))

grid on

N = integral(@(x) y(x), -inf,inf) % should be 1

mu = integral(@(x) x.*y(x), -inf,inf) % mean

var = integral(@(x) (x-mu).^2.*y(x),-inf,inf) % variance

sig = sqrt(var) % standard deviation

% analytical calculations of mu, variance, std deviation

mus = [16 3 9];

sigs = [ 2 1 3];

muA = (1/3)*sum(mus)

varA = (1/3)*(sigs(1)^2 + (mu-mus(1))^2 ...

+ sigs(2)^2 + (mu-mus(2))^2 ...

+ sigs(3)^2 + (mu-mus(3))^2)

sigA = sqrt(varA)

function a = y(x)

% sum of three pdfs

mus = [16 3 9];

sigs = [ 2 1 3];

y1 = normpdf(x,mus(1),sigs(1));

y2 = normpdf(x,mus(2),sigs(2));

y3 = normpdf(x,mus(3),sigs(3));

a = (1/3)*(y1+y2+y3);

end

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
## 0 Comments

Sign in to comment.