Histfit help

4 views (last 30 days)
Mate 2u
Mate 2u on 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 Comment
Oleg Komarov
Oleg Komarov on 18 Feb 2012
Just normalize the counts.

Sign in to comment.

Accepted Answer

Wayne King
Wayne King on 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);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!