Histfit help

5 visualizaciones (últimos 30 días)
Mate 2u
Mate 2u el 18 de Feb. de 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 comentario
Oleg Komarov
Oleg Komarov el 18 de Feb. de 2012
Just normalize the counts.

Iniciar sesión para comentar.

Respuesta aceptada

Wayne King
Wayne King el 18 de Feb. de 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);

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by