Fiting for normalized histrogram.
조회 수: 8 (최근 30일)
이전 댓글 표시
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');
댓글 수: 0
답변 (2개)
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.
댓글 수: 0
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
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!