ksdensity default bandwidth value

조회 수: 29 (최근 30일)
Alexandra
Alexandra 2015년 8월 5일
댓글: Maximiliano Barbosa 2022년 10월 4일
Hi,
Does any one knows how matlab computes the default bandwidth in the function ksdensity?
Thank you very much,

답변 (3개)

FK
FK 2022년 1월 22일
The 'ksdensity' function uses "Silverman's rule" as given in the post of Ghada. The difference between the calculations of Alexandra and the calculations done in Matlab is caused by a different estimation of the the standard deviation. Instead of estimating it by it is done by applying a more robust estimator with (see this Wikipedia article for further information).
With m=[1,3,2,5] you can derive with Silverman's rule that the default bandwith is given by .
  댓글 수: 1
Maximiliano Barbosa
Maximiliano Barbosa 2022년 10월 4일
thank you, actually I was study how to obtain the default bandwith too

댓글을 달려면 로그인하십시오.


Ghada Saleh
Ghada Saleh 2015년 8월 7일
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
Alexandra
Alexandra 2016년 3월 14일
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.

댓글을 달려면 로그인하십시오.


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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by