r""" Function to calculate only the edges of the bins used by the `histogram` function. Parameters ---------- a : array_like Input data. The histogram is computed over the flattened array. bins : int or sequence of scalars or str, optional If `bins` is an int
(a, bins=10, range=None, weights=None)
| 469 | |
| 470 | @array_function_dispatch(_histogram_bin_edges_dispatcher) |
| 471 | def histogram_bin_edges(a, bins=10, range=None, weights=None): |
| 472 | r""" |
| 473 | Function to calculate only the edges of the bins used by the `histogram` |
| 474 | function. |
| 475 | |
| 476 | Parameters |
| 477 | ---------- |
| 478 | a : array_like |
| 479 | Input data. The histogram is computed over the flattened array. |
| 480 | bins : int or sequence of scalars or str, optional |
| 481 | If `bins` is an int, it defines the number of equal-width |
| 482 | bins in the given range (10, by default). If `bins` is a |
| 483 | sequence, it defines the bin edges, including the rightmost |
| 484 | edge, allowing for non-uniform bin widths. |
| 485 | |
| 486 | If `bins` is a string from the list below, `histogram_bin_edges` will use |
| 487 | the method chosen to calculate the optimal bin width and |
| 488 | consequently the number of bins (see `Notes` for more detail on |
| 489 | the estimators) from the data that falls within the requested |
| 490 | range. While the bin width will be optimal for the actual data |
| 491 | in the range, the number of bins will be computed to fill the |
| 492 | entire range, including the empty portions. For visualisation, |
| 493 | using the 'auto' option is suggested. Weighted data is not |
| 494 | supported for automated bin size selection. |
| 495 | |
| 496 | 'auto' |
| 497 | Maximum of the 'sturges' and 'fd' estimators. Provides good |
| 498 | all around performance. |
| 499 | |
| 500 | 'fd' (Freedman Diaconis Estimator) |
| 501 | Robust (resilient to outliers) estimator that takes into |
| 502 | account data variability and data size. |
| 503 | |
| 504 | 'doane' |
| 505 | An improved version of Sturges' estimator that works better |
| 506 | with non-normal datasets. |
| 507 | |
| 508 | 'scott' |
| 509 | Less robust estimator that takes into account data variability |
| 510 | and data size. |
| 511 | |
| 512 | 'stone' |
| 513 | Estimator based on leave-one-out cross-validation estimate of |
| 514 | the integrated squared error. Can be regarded as a generalization |
| 515 | of Scott's rule. |
| 516 | |
| 517 | 'rice' |
| 518 | Estimator does not take variability into account, only data |
| 519 | size. Commonly overestimates number of bins required. |
| 520 | |
| 521 | 'sturges' |
| 522 | R's default method, only accounts for data size. Only |
| 523 | optimal for gaussian data and underestimates number of bins |
| 524 | for large non-gaussian datasets. |
| 525 | |
| 526 | 'sqrt' |
| 527 | Square root (of data size) estimator, used by Excel and |
| 528 | other programs for its speed and simplicity. |