Building a theoretical and empirical distribution function of a random variable (for example, Poisson) in python

Construction of a theoretical and empirical distribution function of a random variable (for example, Poisson) in python. Suppose I have some sample np. array[5,4,5,2,4]. How to construct an empirical distribution function?

Author: user358441, 2019-11-09

1 answers

The empirical distribution function is constructed on the basis of a series of the distribution of the values of a series, which is often confused with a histogram. However, a number of distributions are constructed, for example, by the function numpy.histogram(). The histograms are hist() in Matplotlib and Pandas, displot() in seaborn.

On the other hand, the estimation of the empirical distribution function can be made by the Kernel Density Estimation (KDE) method, and implemented by the functions plot.kde() of the Pandas library, gaussian_kde() in SciPy (scipy.stats), the KDEUnivariate and KDEMultivariate functions in statsmodels.api and KernelDensity() in Scikit-learn.

It is clear that no empirical distribution function can be constructed from five values.

The values of the theoretical distribution function with the specified parameters are obtained in scipy.stats using the methods pdf (for the density of continuous-or pmf for discrete distributions) and cdf (for the integral function) of the corresponding objects, including norm-for the normal distribution or poisson - for Poisson distributions. For example, st.norm.pdf() or st.poisson.pmf().

 1
Author: passant, 2020-05-17 18:36:53