Histfit help

5 Ansichten (letzte 30 Tage)
Mate 2u
Mate 2u am 18 Feb. 2012
Hi there, I am trying to plot a PDF of some distributions on my data which are a set of financial daily returns using HISTFIT.
Problem is I want it to be in terms of probability on the y-axis but I get large values like 10-30 (it is just density).
Is there a way I can make this probabilities?
I hope somebody can help.
  1 Kommentar
Oleg Komarov
Oleg Komarov am 18 Feb. 2012
Just normalize the counts.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Wayne King
Wayne King am 18 Feb. 2012
Hi, One way:
% generate 1,000 N(10,2^2) RVs
R = normrnd(10,2,1e3,1);
% get an estimate of mu and sigma from the "data"
[muhat,sigma] = normfit(R);
% construct histogram
[F,X] = hist(R,30);
% get ready to plot as probability histogram
F = F/trapz(X,F);
bar(X,F); hold on;
% use muhat and sigma to construct pdf
x = muhat-3*sigma:0.01:muhat+3*sigma;
% plot PDF over histogram
y = normpdf(x,muhat,sigma);
plot(x,y,'r','linewidth',2);

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by