Get parameters for normal distributions in Kernel fit of probability distribution

4 views (last 30 days)
Using Kernel to fit a series of normal distributions, how can you read out the means and sigmas of the normals it comes up with?
Also, is there a way to set the number of peaks it uses?
Thanks in advance!

Accepted Answer

Cam Salzberger
Cam Salzberger on 31 Aug 2015
Hello Darin,
I understand that you would like to get information on the normal distributions that make up the Kernal distribution. I assume that the Kernal distribution is calculated using the fitdist function.
If you check out the "Kernal Smoothing Function" example on the Kernal distribution documentation page, you can see that they actually plot the normal distributions that make up that particular Kernal distribution.
The mean of each normal distribution will be one of the data points, and the sigma of each normal distribution will be the 'BandWidth' of the Kernal distribution. Each normal distribution has the same standard deviation.
For example, if you wanted to modify that example, you could allow the default 'BandWidth' to be chosen, and add together the calculated normal distributions to show that they are the same as the plotted Kernal distribution:
% Plot the Kernal distribution
SixMPG = [13;15;23;29;32;34];
figure;
pdSix = fitdist(SixMPG,'Kernel');
x = 0:.1:45;
ySix = pdf(pdSix,x);
plot(x,ySix,'k-','LineWidth',2);
% Plot each individual normal distribution and scale its appearance on the plot
hold on;
yNormSum = zeros(size(ySix));
for i=1:6
pd = makedist('Normal','mu',SixMPG(i),'sigma',pdSix.BandWidth);
y = pdf(pd,x);
y = y/6;
plot(x,y,'b:');
yNormSum = yNormSum+y;
end
plot(x,yNormSum,'g--','LineWidth',1.5)
hold off

More Answers (0)

Community Treasure Hunt

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

Start Hunting!