Borrar filtros
Borrar filtros

Plot Normal/Gaussian distribution from set of data

20 visualizaciones (últimos 30 días)
Kash022
Kash022 el 7 de Abr. de 2016
Comentada: Kash022 el 7 de Abr. de 2016
Hello All,
I want to plot a gaussian distribution of a set of data and see the mean and 3 sigma. I am using the below code but I am not getting the gaussian curve. Please help! Thanks!
x = [2.9954E-09,3.1314E-09,3.1155E-09,3.0940E-09,2.8861E-09,3.0875E-09,2.9685E-09,3.0532E-09,2.9003E-09,3.0931E-09];
[mu,s]=normfit(x,0,1);
%norm=normpdf(x,0,1);
figure; plot(x,norm);
figure; plot(x,norm);
  1 comentario
Kash022
Kash022 el 7 de Abr. de 2016
I have managed to write this but can't calculate and plot mean and sigma.
x = [2.9954E-09 3.1314E-09 3.1155E-09 3.0940E-09 2.8861E-09 3.0875E-09 2.9685E-09 3.0532E-09 2.9003E-09 3.0931E-09];
norm=histfit(x,10,'normal');
plot(x,norm);

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 7 de Abr. de 2016
Try this:
x = [2.9954E-09 3.1314E-09 3.1155E-09 3.0940E-09 2.8861E-09 3.0875E-09 2.9685E-09 3.0532E-09 2.9003E-09 3.0931E-09];
norm=histfit(x,10,'normal')
[muHat, sigmaHat] = normfit(x);
% Plot bounds at +- 3 * sigma.
lowBound = muHat - 3 * sigmaHat;
highBound = muHat + 3 * sigmaHat;
yl = ylim;
line([lowBound, lowBound], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
line([highBound, highBound], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
line([muHat, muHat], yl, 'Color', [0, .6, 0], 'LineWidth', 3);
grid on;
% xFit = linspace(min(x), max(x), 100);
% yFit = max(x) * exp(-(xFit - muHat).^2/sigmaHat^2);
% figure;
% plot(xFit, yFit, 'r-', 'LineWidth', 2);
% grid on;
% Set up figure properties:
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Get rid of tool bar and pulldown menus that are along top of figure.
set(gcf, 'Toolbar', 'none', 'Menu', 'none');
% Give a name to the title bar.
set(gcf, 'Name', 'Line segmentation', 'NumberTitle', 'Off')
  1 comentario
Kash022
Kash022 el 7 de Abr. de 2016
Thanks! It works. Is there a way where I can show on the plot the mean and the 3 sigma?like an arrow showing the extent of the sigma?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by