Plotting a histogram density estimator
Mostrar comentarios más antiguos
Hello everyone,
Kindly assist me in writing a Matlab code to plot the histogram density estimator using Scott rule.
I tried the following but didnt get a result:
n=length(a); % sample size
s = std(a);
h = 3.5*s*(length(a)).^(-1/3);
% compute the skew factor (for histograms):
sf = ((2.^(1/3)).*s) / ( exp(5.*s.^2/4) .* ((s.^2 + 2).^(1/3)) .* (exp(s.^2) - 1).^(1/2) );
h = h*sf;
% get the limits, bins, bin centers etc:
x_lim_left = min(x)-1;
x_lim_rght = max(x)+1;
t0 = x_lim_left;
tm = x_lim_rght;
rng = tm-t0;
nbin = ceil(rng./h);
bins = t0:h:(nbin.*h+t0); % <- the bin edges ...
%bc = bins(1:end-1)+h./2; % <- the bin centers ...
x(x<x_lim_left)=x_lim_left;
x(x>x_lim_rght)=x_lim_rght;
vk=histc(x,bins); vk(end)=[];
% normalize:
fhat = vk/(n.*h);
1 comentario
Star Strider
el 26 de Abr. de 2015
What do you mean by ‘didn’t get a result’?
I’m not certain where you’re your getting your expressions (I wasn’t aware of Scott’s paper until I went looking for it), but your expression for the skewness factor doesn’t resemble the expression on the top of page 6 (for the normal density).
Perhaps going into more detail will help. I’m not certain what you want to do.
Respuestas (0)
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!