Skip to content

Commit d734c68

Browse files
committed
docstrings
1 parent 269dd75 commit d734c68

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

pymc_extras/distributions/discrete.py

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -442,25 +442,49 @@ def sim_data(lam):
442442

443443

444444
class GrassiaIIGeometric(UnitContinuous):
445-
r"""Grassia(II)-Geometric distribution for a discrete-time, contractual customer population.
445+
r"""Grassia(II)-Geometric distribution.
446446
447-
Described by Hardie and Fader in [1]_, this distribution is comprised by the following PMF and survival functions:
447+
This distribution is a flexible alternative to the Geometric distribution for the
448+
number of trials until a discrete event, and can be easily extended to support both static
449+
and time-varying covariates.
450+
451+
Hardie and Fader describe this distribution with the following PMF and survival functions in [1]_:
448452
449453
.. math::
450454
\mathbb{P}T=t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t-1)})^{r} - (\frac{\alpha}{\alpha+C(t)})^{r} \\
451455
\begin{align}
452456
\mathbb{S}(t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t)})^{r} \\
453457
\end{align}
458+
459+
.. plot::
460+
:context: close-figs
461+
462+
import matplotlib.pyplot as plt
463+
import numpy as np
464+
import scipy.stats as st
465+
import arviz as az
466+
plt.style.use('arviz-darkgrid')
467+
t = np.arange(1, 11)
468+
alpha_vals = [1., 1., 2., 2.]
469+
r_vals = [.1, .25, .5, 1.]
470+
for alpha, r in zip(alpha_vals, r_vals):
471+
pmf = (alpha/(alpha + t - 1))**r - (alpha/(alpha+t))**r
472+
plt.plot(t, pmf, '-o', label=r'$\alpha$ = {}, $r$ = {}'.format(alpha, r))
473+
plt.xlabel('t', fontsize=12)
474+
plt.ylabel('p(t)', fontsize=12)
475+
plt.legend(loc=1)
476+
plt.show()
477+
454478
======== ===============================================
455-
Support :math:`0 < t <= T` for :math: `t = 1, 2, \dots, T`
479+
Support :math:`t \in \mathbb{N}_{>0}`
456480
======== ===============================================
457481
458482
Parameters
459483
----------
460484
r : tensor_like of float
461-
Shape parameter of Gamma distribution describing customer heterogeneity. (r > 0)
485+
Shape parameter (r > 0).
462486
alpha : tensor_like of float
463-
Scale parameter of Gamma distribution describing customer heterogeneity. (alpha > 0)
487+
Scale parameter (alpha > 0).
464488
465489
References
466490
----------

0 commit comments

Comments
 (0)