フィルターのクリア

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 Center および File ExchangeHistograms についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by