Filter löschen
Filter löschen

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

4 Ansichten (letzte 30 Tage)
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);

Akzeptierte Antwort

Steven Lord
Steven Lord am 11 Sep. 2018
Bearbeitet: Steven Lord am 30 Okt. 2018
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 Kommentare
Steven Lord
Steven Lord am 11 Sep. 2018
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 am 11 Sep. 2018
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Particle & Nuclear Physics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by