From: Tom on
Hi,

I am using the normspec function to plot the distribution for a given mean and standard deviation, and then finding the probability between two limits:

normspec([limit1, limit2], mean, std)

I was wondering if I could obtain the function of the curve which the normspec result produces? - for use elsewhere?

Regards,
Tom
From: Wayne King on
"Tom" <tom(a)myers16.fsnet.co.uk> wrote in message <htljha$7ua$1(a)fred.mathworks.com>...
> Hi,
>
> I am using the normspec function to plot the distribution for a given mean and standard deviation, and then finding the probability between two limits:
>
> normspec([limit1, limit2], mean, std)
>
> I was wondering if I could obtain the function of the curve which the normspec result produces? - for use elsewhere?
>
> Regards,
> Tom

Hi Tom, you can use fill() to fill in the region you want delimited on any probability density. For example, compare:

normspec([-1 1],0,1);

with the following:

x = -3:.01:3;
y = normpdf(x,0,1);
plot(x,y); hold on;
xlow = [-1 -1];
ylow = [0 normpdf(-1,0,1)];
xupp = [1 1];
yupp = [normpdf(1,0,1) 0];
plot(xlow,ylow,'b',xupp,yupp,'b');
indices = find(x> -1 & x< 1);
xvalues = [xlow'; x(indices)'; xupp'];
yvalues = [ylow'; y(indices)'; yupp'];
fill(xvalues,yvalues,'b');

Hope that helps,
Wayne