Effacer les filtres
Effacer les filtres

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

4 vues (au cours des 30 derniers jours)
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);

Réponse acceptée

Steven Lord
Steven Lord le 11 Sep 2018
Modifié(e) : Steven Lord le 30 Oct 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 commentaires
Steven Lord
Steven Lord le 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 le 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Particle & Nuclear Physics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by