ksdensity default bandwidth value

17 views (last 30 days)
Alexandra
Alexandra on 5 Aug 2015
Hi,
Does any one knows how matlab computes the default bandwidth in the function ksdensity?
Thank you very much,

Answers (2)

Ghada Saleh
Ghada Saleh on 7 Aug 2015
Hello Alexandra,
In MATLAB, the default bandwidth in 'ksdensity' function is calculated using the following formula:
BandWidth = sig * (4/(3*N))^(1/5);
where 'sig' is an estimated value of the standard deviation of the samples.
I hope this helps,
Ghada
  1 Comment
Alexandra
Alexandra on 14 Mar 2016
I have used this formula to test the calculations of the bandwidth and I don't think it is correct.
Take a simple example: m=[1,3,2,5] Then from [a,b,c]=ksdensity(m,m,'function','cdf') c=1.1901 and sig*(4/(3*4))^(1/5)= 1.3709 So they don't yield the same answers.

Sign in to comment.


Mohammad Khatamirad
Mohammad Khatamirad on 4 Dec 2017
you can try this: [f, xi, bw] = ksdensity(X); bw = 'gives you the default bandwidth'

Tags

Community Treasure Hunt

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

Start Hunting!