histfit using Kernel function with a specific bandwith?

1 回表示 (過去 30 日間)
Dan
Dan 2013 年 10 月 10 日
Hi,
Can anyone tell me if there is way use histfit with a Kernel function, but also choose the bandwidth for the Kernel function. For example, I know I can use histfit like this:
histfit(data,10,'kernel')
...and get a nice fitted histogram with 10 bins. But, how can I change the bandwidth that is used in the Kernel function? I know how to do this using ksdensity:
[f,xi] = ksdensity(data,'width',mywidth)
...can this be applied to histfit?
Thanks in advance, Dan.

回答 (1 件)

Dan
Dan 2013 年 10 月 10 日
Sorry for answering my own question, but I figured it out. I just made a modified version of histfit for the kernel function distribution. I modified line 61 in histfit to:
pd = fitdist(data,dist,'width',w);
and added the input option of w. The beauty of open source code!
  2 件のコメント
Mark van den Bosch
Mark van den Bosch 2021 年 6 月 13 日
Great answer!
Francesca Lo Iacono
Francesca Lo Iacono 2022 年 3 月 23 日
Hi!
is the following line the only one you have modified?
"pd = fitdist(data,dist,'width',w);"

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by