Borrar filtros
Borrar filtros

normalize a histogram in pdf mode

5 visualizaciones (últimos 30 días)
MG
MG el 14 de Nov. de 2015
Respondida: the cyclist el 27 de Dic. de 2016
I am trying to normalize my histograms so that my gaussian curves can fit over them (right now, the histograms and gaussians are not on the same scale so the gaussians look really tiny. How do I fix this? I tried doing histogram(midterm,bins)./sum(histogram(midterm,bins)) but matlab didn't like that and said "Undefined function 'sum' for input arguments of type 'matlab.graphics.chart.primitive.Histogram'."
[num, txt, raw] = xlsread('grades.xlsx')
midterm = num(:,2);
t = tabulate(midterm);
scores = t(:,1);
counts = t(:,2);
assign = num(:,1);
bins = 0:15;
firstp = makeNormalDis(13.8306,1.3311);
secondp = makeNormalDis(10.7675,1.9410);
x = [0,15];
figure;
a = histogram(midterm, bins); hold on;
b = histogram(assign, bins);
fplot(firstp, x, 'r');
set(findobj(gca, 'Type', 'Line', 'Color', 'r'), 'LineWidth', 1.5);
fplot(secondp, x, 'b');
set(findobj(gca, 'Type', 'Line', 'Color', 'b'), 'LineWidth', 1.5); hold off
set(gca,'XTick',bins);
ylabel('Normalized PDF');
xlabel('Grades');
legend('Midterm', 'Assignment 1', 'Location', 'northwest');
grid on;

Respuestas (1)

the cyclist
the cyclist el 27 de Dic. de 2016
Set the Normalization property of the histogram object. Here is an example:
h = histogram(randn(100000,1));
h.Normalization='probability'

Categorías

Más información sobre Histograms en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by