フィルターのクリア

can anyone tell me an intuitive way of finding number of bins for histcounts function

4 ビュー (過去 30 日間)
The binning algorithm used by matlab is very expensive [N,edges] = histcounts(I) Instead I am looking for some different and computationally less expensive ways in which we can find the bins [N,edges] = histcounts(I,bins);

採用された回答

Steven Lord
Steven Lord 2018 年 9 月 11 日
編集済み: Steven Lord 2018 年 10 月 30 日
There are several different possible BinMethod values available for histcounts. The default is 'auto' which attempts to find a "good" choice of bin width. That does take some effort. Consider explicitly specifying one of the other options. The 'sturges' and 'sqrt' BinMethods are probably going to be the least computationally intensive, as instead of performing computations on the whole data set ('scott' calls std and 'fd' computes the IQR) they use numel(x) in their calculations.
Or if you have a sense of how wide the bins you want to use are and where the first and last bins should be located, you can specify the bin edges vector yourself as the second input. But this requires you to have some knowledge of the data on which you're operating.
[SL: fixed a typo, "IRQ" -> "IQR"]
  3 件のコメント
Steven Lord
Steven Lord 2018 年 9 月 11 日
Call histcounts and specify the 'BinMethod' option. On the documentation page for the histcount function see the "Determine Bin Placement" example. That example uses the 'integers' BinMethod, so to use sturges or sqrt change 'integers' to 'sturges' or 'sqrt'.
Walter Roberson
Walter Roberson 2018 年 9 月 11 日
sturges: look somewhere near line 440 of histcounts to see the sturgesrule function. It calls matlab.internal.math.binpicker
>> which -all matlab.internal.math.binpicker
/Applications/MATLAB_R2018a.app/toolbox/matlab/datafun/+matlab/+internal/+math/binpicker.m % static method or package function
You can edit that.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by