Kernel estimates using Gaussian.. Its working with histogram at the moment !!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey all...
I am trying to get the kernel work using Gaussian now.. I have it with histogram, I tried to find any relevant articles regarding the Gaussian technique in MATLAB but could not find.. I made it in different subplot to see what I am doing.. in this link it will show what I mean by Gaussian on each data plot(red dashes) rather than histogram..
https://www.ifas.jku.at/Portale/Institute/SOWI_Institute/ifas/content/e2550/e2770/e6038/files6234/JKU07HP.pdf?preview=preview
here is what I have and Its working for the histogram..
function Sa = trial(lambdaMax,lambda,T)
t = 0;
I = 0;
Sa = [];
u = rand;
t = t - log(u)/lambdaMax;
while t <= T
if (u <= lambda(t)/lambdaMax)
I = I+1;
Sa(I) = t;
end
u = rand;
t = t - log(u)/lambdaMax;
u=rand;
end
Script to run it,
lambdaMax=50;
T=20;
lambda =@(Sa) lambdaMax*(cos(Sa));
Sa = trial(lambdaMax,lambda,T);
figure
hold on
plot(Sa,lambda(Sa))
xlabel('t')
ylabel ('cos(x)')
X = linspace(min(Sa),max(Sa),100);
Y = pchip(Sa,lambda(Sa),X);
subplot(2,2,1)
plot(X,Y)
line(repmat(Sa,2,1),repmat([0;1],1,length(Sa)),'color','r' )
[f,xi] = ksdensity(Y);
subplot(2,2,2)
hist(Y)
subplot(2,2,3)
plot(xi,sum(Y)*f/sum(f),'g.-')
0 Kommentare
Akzeptierte Antwort
the cyclist
am 14 Jul. 2011
In the line where you call ksdensity, it looks like you have the wrong input. Does this give what you expect?
[f,xi] = ksdensity(Sa,'width',0.2);
4 Kommentare
the cyclist
am 18 Jul. 2011
That is the width of the gaussian kernel used for the estimation. This is explained in the help file for the ksdensity() function. You might also look at the section "Bandwidth Selection" on this page: http://en.wikipedia.org/wiki/Kernel_density_estimation
[Please accept this answer if you found it useful. That might help future users who have questions on kernel density estimation.]
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!