scikitplot.stats#

scikitplot.stats#

Elegant statistical tools for intuitive and insightful data visualization and interpretation.

The stats module offers a wide range of probability distributions, summary and frequency statistics, correlation functions, statistical tests, masked statistics, and additional tools.

User guide. See the Stats section for further details.

Astrostatistics: Bayesian Blocks for Time Series Analysis#

User guide. See the Astrostatistics Tools (experimental) section for further details.

Events

Bayesian blocks fitness for binned or unbinned events.

FitnessFunc

Base class for bayesian blocks fitness functions.

PointMeasures

Bayesian blocks fitness for point measures.

RegularEvents

Bayesian blocks fitness for regular events.

bayesian_blocks

Compute optimal segmentation of data with Scargle's Bayesian Blocks.

Astrostatistics Tools#

This module contains simple statistical algorithms that are straightforwardly implemented as a single python function (or family of functions).

This module should generally not be used directly. Everything in __all__ is imported into astropy.stats, and hence that package should be used for access.

User guide. See the Astrostatistics Tools (experimental) section for further details.

binned_binom_proportion

Binomial proportion and confidence interval in bins of a continuous variable x.

binom_conf_interval

Binomial proportion confidence interval given k successes, n trials.

bootstrap

Performs bootstrap resampling on numpy arrays.

cdf_from_intervals

Construct a callable piecewise-linear CDF from a pair of arrays.

fold_intervals

Fold the weighted intervals to the interval (0,1).

gaussian_fwhm_to_sigma

Convert a string or number to a floating-point number, if possible.

gaussian_sigma_to_fwhm

Convert a string or number to a floating-point number, if possible.

histogram_intervals

Histogram of a piecewise-constant weight function.

interval_overlap_length

Compute the length of overlap of two intervals.

kuiper

Compute the Kuiper statistic.

kuiper_false_positive_probability

Compute the false positive probability for the Kuiper statistic.

kuiper_two

Compute the Kuiper statistic to compare two samples.

mad_std

Calculate a robust standard deviation using the median absolute deviation (MAD).

median_absolute_deviation

Calculate the median absolute deviation (MAD).

poisson_conf_interval

Poisson parameter confidence interval given observed counts.

signal_to_noise_oir_ccd

Computes the signal to noise ratio for source being observed in the optical/IR using a CCD.

Astrostatistics: Selecting the bin width of histograms#

calculate_bin_edges

Calculate histogram bin edges like numpy.histogram_bin_edges.

freedman_bin_width

Return the optimal histogram bin width using the Freedman-Diaconis rule.

histogram

Enhanced histogram function, providing adaptive binnings.

knuth_bin_width

Return the optimal histogram bin width using Knuth's rule.

scott_bin_width

Return the optimal histogram bin width using Scott's rule.

Astrostatistics: Model Selection#

This module contains simple functions for model selection.

User guide. See the Astrostatistics Tools (experimental) section for further details.

akaike_info_criterion

Computes the Akaike Information Criterion (AIC).

akaike_info_criterion_lsq

Computes the Akaike Information Criterion assuming that the observations are Gaussian distributed.

bayesian_info_criterion

Computes the Bayesian Information Criterion (BIC) given the log of the likelihood function evaluated at the estimated (or analytically derived) parameters, the number of parameters, and the number of samples.

bayesian_info_criterion_lsq

Computes the Bayesian Information Criterion (BIC) assuming that the observations come from a Gaussian distribution.

Astrostatistics: Robust Biweight Estimators#

This module contains functions for computing robust statistics using Tukey’s biweight function.

User guide. See the Astrostatistics Tools (experimental) section for further details.

biweight_location

Compute the biweight location.

biweight_midcorrelation

Compute the biweight midcorrelation between two variables.

biweight_midcovariance

Compute the biweight midcovariance between pairs of multiple variables.

biweight_midvariance

Compute the biweight midvariance.

biweight_scale

Compute the biweight scale.

Astrostatistics: Sigma Clipping#

User guide. See the Astrostatistics Tools (experimental) section for further details.

SigmaClip

Class to perform sigma clipping.

SigmaClippedStats

Class to calculate sigma-clipped statistics on the provided data.

sigma_clip

Perform sigma-clipping on the provided data.

sigma_clipped_stats

Calculate sigma-clipped statistics on the provided data.

Astrostatistics: Circular Statistics#

This module contains simple functions for dealing with circular statistics, for instance, mean, variance, standard deviation, correlation coefficient, and so on. This module also cover tests of uniformity, e.g., the Rayleigh and V tests. The Maximum Likelihood Estimator for the Von Mises distribution along with the Cramer-Rao Lower Bounds are also implemented. Almost all of the implementations are based on reference [1]_, which is also the basis for the R package ‘CircStats’ [2]_.

User guide. See the Astrostatistics Tools (experimental) section for further details.

circcorrcoef

Computes the circular correlation coefficient between two array of circular data.

circmean

Computes the circular mean angle of an array of circular data.

circmoment

Computes the p-th trigonometric circular moment for an array of circular data.

circstd

Computes the circular standard deviation of an array of circular data.

circvar

Computes the circular variance of an array of circular data.

rayleightest

Performs the Rayleigh test of uniformity.

vonmisesmle

Computes the Maximum Likelihood Estimator (MLE) for the parameters of the von Mises distribution.

vtest

Performs the Rayleigh test of uniformity where the alternative hypothesis H1 is assumed to have a known mean angle mu.

Astrostatistics: Jackknife Resampling#

User guide. See the Astrostatistics Tools (experimental) section for further details.

jackknife_resampling

Performs jackknife resampling on numpy arrays.

jackknife_stats

Performs jackknife estimation on the basis of jackknife resamples.

Astrostatistics: Spatial Statistics#

This module implements functions and classes for spatial statistics.

User guide. See the Astrostatistics Tools (experimental) section for further details.

RipleysKEstimator

Estimators for Ripley's K function for two-dimensional spatial data.

Discrete Distributions Tools#

Tweedie Distribution Module.

This module implements the Tweedie distribution, a member of the exponential dispersion model (EDM) family, using SciPy’s rv_continuous class.

It is especially useful for modeling claim amounts in the insurance industry, where data often exhibit a mixture of zeroes and positive continuous values.

The primary focus of this package is the compound-Poisson behavior of the Tweedie distribution, particularly in the range 1 < p < 2. However, it supports calculations for all valid values of the shape parameter p.

Notes

The probability density function (PDF) of the Tweedie distribution cannot be expressed in a closed form for most values of p. However, approximations and numerical methods are employed to compute the PDF for practical purposes.

The Tweedie distribution family includes several well-known distributions based on the value of the shape parameter p:

  • p = 0 : Normal distribution

  • p = 1 : Poisson distribution

  • 1 < p < 2 : Compound Poisson-Gamma distribution

  • p = 2 : Gamma distribution

  • 2 < p < 3 : Positive stable distributions

  • p = 3 : Inverse Gaussian distribution

  • p > 3 : Positive stable distributions

The Tweedie distribution is undefined for values of p in the range (0, 1).

References

[1] Jørgensen, B. (1987). “Exponential dispersion models”.

Journal of the Royal Statistical Society, Series B. 49 (2): 127–162.

[2] Tweedie, M. C. K. (1984). “An index which distinguishes between some important exponential families”.

In Statistics: Applications and New Directions. Proceedings of the Indian Statistical Institute Golden Jubilee International Conference.

[3] [YouTube]

Statistical Methods Series: Zero-Inflated GLM and GLMM.

[4] [Google]

https://www.statisticshowto.com/tweedie-distribution/

User guide. See the Tweedie Distribution (generalized family) section for further details.

tweedie_gen

A Tweedie continuous random variable inherited scipy.stats.rv_continuous.

tweedie

An instance of tweedie_gen, providing Tweedie distribution functionality.