필터 지우기
필터 지우기

Fiting for normalized histrogram.

조회 수: 8 (최근 30일)
Andrew Kim
Andrew Kim 2020년 11월 4일
편집: Pradeesh 2020년 11월 5일
Hi
I want to make a fit for my histogram that is normalized. The histfit function does not seem to normalize with probability. Can somebody help me fit the histogram written below?
step = 1000; % Shows the number of steps
P = zeros(step,1);
x = [1:10000];
added = 0;
d = 0;
for i=1:10000 %The simulation repeats for 100,000 times
added = 0;
for j=2:step
R = rand;
if R < 0.5
S = -1;
elseif R > 0.5
S = 1;
end
P(j) = S+P(j-1);
end
x(i) = P(length(P));
added = added + x(i);
end
histogram(x,'Normalization','probability');

답변 (2개)

Star Strider
Star Strider 2020년 11월 5일
Divide the ‘Bar’ object and the ‘Line’ object by thier maximum values:
figure
hfh = histfit(x);
hfh(1).YData = hfh(1).YData/max(hfh(1).YData);
hfh(2).YData = hfh(2).YData/max(hfh(2).YData);
That should produce the result you want.

Pradeesh
Pradeesh 2020년 11월 5일
편집: Pradeesh 2020년 11월 5일
You may follow the documentation to use the following function for fitting normalized histogram for which a sample fit for normalized histogram is provided.
fitdist

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by