Azzera filtri
Azzera filtri

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

4 visualizzazioni (ultimi 30 giorni)
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);

Risposta accettata

Steven Lord
Steven Lord il 11 Set 2018
Modificato: Steven Lord il 30 Ott 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 Commenti
Steven Lord
Steven Lord il 11 Set 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 il 11 Set 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.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by