optimal_bins¶
- rubin_sim.maf.utils.optimal_bins(datain, binmin=None, binmax=None, nbin_max=200, nbin_min=1)¶
Set an ‘optimal’ number of bins using the Freedman-Diaconis rule.
- Parameters:
- datainnumpy.ndarray or numpy.ma.MaskedArray
The data for which we want to set the bin_size.
- binminfloat
The minimum bin value to consider (if None, uses minimum data value).
- binmaxfloat
The maximum bin value to consider (if None, uses maximum data value).
- nbin_maxint
The maximum number of bins to create. Sometimes the ‘optimal bin_size’ implies an unreasonably large number of bins, if the data distribution is unusual.
- nbin_minint
The minimum number of bins to create. Default is 1.
- Returns:
- int
The number of bins.