Fiting for normalized histrogram.
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (2)
Star Strider
am 5 Nov. 2020
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 Kommentare
Pradeesh
am 5 Nov. 2020
Bearbeitet: Pradeesh
am 5 Nov. 2020
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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!