필터 지우기
필터 지우기

normalize a histogram in pdf mode

조회 수: 3 (최근 30일)
MG
MG 2015년 11월 14일
답변: the cyclist 2016년 12월 27일
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;

답변 (1개)

the cyclist
the cyclist 2016년 12월 27일
Set the Normalization property of the histogram object. Here is an example:
h = histogram(randn(100000,1));
h.Normalization='probability'

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by