Astrostatistics Tools (astropy.stats)


The astropy.stats package holds statistical functions or algorithms used in astronomy and astropy.

Getting Started

The current tools are fairly self-contained, and include relevant examples in their docstrings.

See Also


astropy.stats Package

This subpackage contains statistical tools provided for or used by Astropy.

While the scipy.stats package contains a wide range of statistical tools, it is a general-purpose package, and is missing some that are particularly useful to astronomy or are used in an atypical way in astronomy. This package is intended to provide such functionality, but not to replace scipy.stats if its implementation satisfies astronomers’ needs.


bayesian_blocks(t[, x, sigma, fitness]) Compute optimal segmentation of data with Scargle’s Bayesian Blocks
binned_binom_proportion(x, success[, bins, ...]) Binomial proportion and confidence interval in bins of a continuous variable x.
binom_conf_interval(k, n[, conf, interval]) Binomial proportion confidence interval given k successes, n trials.
biweight_location(a[, c, M]) Compute the biweight location for an array.
biweight_midvariance(a[, c, M]) Compute the biweight midvariance for an array.
bootstrap(data[, bootnum, samples, bootfunc]) Performs bootstrap resampling on numpy arrays.
freedman_bin_width(data[, return_bins]) Return the optimal histogram bin width using the Freedman-Diaconis rule
histogram(a[, bins, range, weights]) Enhanced histogram function, providing adaptive binnings
knuth_bin_width(data[, return_bins, quiet]) Return the optimal histogram bin width using Knuth’s rule.
mad_std(data) Calculate a robust standard deviation using the median absolute deviation (MAD).
median_absolute_deviation(a[, axis]) Compute the median absolute deviation.
poisson_conf_interval(n[, interval, sigma]) Poisson parameter confidence interval given observed counts
scott_bin_width(data[, return_bins]) Return the optimal histogram bin width using Scott’s rule
sigma_clip(data[, sigma, sigma_lower, ...]) Perform sigma-clipping on the provided data.
sigma_clipped_stats(data[, mask, ...]) Calculate sigma-clipped statistics from data.
signal_to_noise_oir_ccd(t, source_eps, ...) Computes the signal to noise ratio for source being observed in the optical/IR using a CCD.


Events([p0, gamma, ncp_prior]) Bayesian blocks fitness for binned or unbinned events
FitnessFunc([p0, gamma, ncp_prior]) Base class for bayesian blocks fitness functions
PointMeasures([p0, gamma, ncp_prior]) Bayesian blocks fitness for point measures
RegularEvents(dt[, p0, gamma, ncp_prior]) Bayesian blocks fitness for regular events

Class Inheritance Diagram

Inheritance diagram of astropy.stats.bayesian_blocks.Events, astropy.stats.bayesian_blocks.FitnessFunc, astropy.stats.bayesian_blocks.PointMeasures, astropy.stats.bayesian_blocks.RegularEvents