# spacepy.toolbox.bootHisto

`spacepy.toolbox.``bootHisto`(data, inter=90.0, n=1000, seed=None, plot=False, target=None, figsize=None, loc=None, **kwargs)

  Bootstrap confidence intervals for a histogram.

  All other keyword arguments are passed to `numpy.histogram()` or `matplotlib.pyplot.bar()`.

  Parameters
    data array_like

      list/array of data values

    inter float (optional; default 90)

      percentage confidence interval to return. Default 90% (i.e. lower CI will be 5% and upper will be 95%)

    n int (optional; default 1000)

      number of bootstrap iterations

    seed int (optional)

      Optional seed for the random number generator. If not specified; numpy generator will not be reseeded.

    plot bool (optional)

      Plot the result. Plots if True or `target`, `figsize`, or `loc` specified.

    target(optional)

      Target on which to plot the figure (figure or axes). See `spacepy.plot.utils.set_target()` for details.

    figsize tuple (optional)

      Passed to `spacepy.plot.utils.set_target()`.

    loc int (optional)

      Passed to `spacepy.plot.utils.set_target()`.

  Returns
    out tuple

      tuple of bin_edges, low, high, sample[, bars]. Where `bin_edges` is the edges of the bins used; `low` is the histogram with the value for each bin from the bottom of that bin’s confidence interval; `high` similarly for the top; `sample` is the histogram of the input sample without resampling. If plotting, also returned is `bars`, the container object returned from matplotlib.

  See also

  `binHisto`
  `plot.utils.set_target`
  `numpy.histogram`
  `matplotlib.pyplot.hist`

  Notes

  The confidence intervals are calculated for each bin individually and thus the resulting low/high histograms may not have actually occurred in the calculation from the surrogates. If using a probability density histogram, this can have “interesting” implications for interpretation.

  Examples

      >>> import numpy.random
      >>> import spacepy.toolbox
      >>> numpy.random.seed(0)
      >>> data = numpy.random.randn(1000)
      >>> bin_edges, low, high, sample, bars = spacepy.toolbox.bootHisto(
      ...     data, plot=True)

  (Source code, png, hires.png, pdf)