Probability Distributions and their Stories

Given any module that deals with statistics, one basic skill you must have is to be able to program and create plots of probability distributions typically encountered in the field of data science. This tutorial should remind you of various distributions introduced in this section, but now they are phrased using the scipy.stats module.

Continuous distributions

Weibull distribution

  • Story. Distribution of x=y^β if y is exponentially distributed. For β>1, the longer we have waited, the more likely the event is to come, and vice versa for β.
  • Example. This is a model for aging. The longer an organism lives, the more likely it is to die.
  • Parameters. There are two parameters, both strictly positive: the shape parameter β, which dictates the shape of the curve, and the scale parameter τ, which dictates the rate of arrivals of the event.
  • Support. The Weibull distribution has support on the positive real numbers.
  • Probability density function.

    \begin{align}f(y;\alpha, \sigma) = \frac{\alpha}{\sigma}\left(\frac{y}{\sigma}\right)^{\alpha - 1}\,\mathrm{e}^{-(y/\sigma)^\alpha}.\end{align}

  • Usage

    Package Syntax
    NumPy np.random.weibull(alpha) * sigma
    SciPy `scipy.stats.weibull_min(alpha, loc=0, scale=sigma)
    Stan weibull(alpha, sigma)

  • Related distributions.
    • The special case where α=0 is the Exponential distribution with parameter β=1/σ.
  • Notes.
    • SciPy has a location parameter, which should be set to zero, with β being the scale parameter.
    • NumPy only provides a version of the Weibull distribution with σ=1. Sampling out of the Weibull distribution may be accomplished by multiplying the resulting samples by σ.
params = [dict(name='α', start=0.1, end=5, value=1, step=0.01),
          dict(name='σ', start=0.1, end=3, value=1.5, step=0.01)]
app = distribution_plot_app(x_min=0,
                            x_max=8,
                            scipy_dist=st.weibull_min,
                            params=params,
                            transform=lambda a, s: (a, 0, s),
                            x_axis_label='y',
                            title='Weibull')
bokeh.io.show(app, notebook_url=notebook_url)