Histfit help
4 views (last 30 days)
Show older comments
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.
Accepted Answer
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);
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!