@@ -442,25 +442,49 @@ def sim_data(lam):
442
442
443
443
444
444
class GrassiaIIGeometric (UnitContinuous ):
445
- r"""Grassia(II)-Geometric distribution for a discrete-time, contractual customer population .
445
+ r"""Grassia(II)-Geometric distribution.
446
446
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]_:
448
452
449
453
.. math::
450
454
\mathbb{P}T=t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t-1)})^{r} - (\frac{\alpha}{\alpha+C(t)})^{r} \\
451
455
\begin{align}
452
456
\mathbb{S}(t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t)})^{r} \\
453
457
\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
+
454
478
======== ===============================================
455
- Support :math:`0 < t <= T` for :math: `t = 1, 2, \dots, T `
479
+ Support :math:`t \in \mathbb{N}_{>0} `
456
480
======== ===============================================
457
481
458
482
Parameters
459
483
----------
460
484
r : tensor_like of float
461
- Shape parameter of Gamma distribution describing customer heterogeneity. (r > 0)
485
+ Shape parameter (r > 0).
462
486
alpha : tensor_like of float
463
- Scale parameter of Gamma distribution describing customer heterogeneity. (alpha > 0)
487
+ Scale parameter (alpha > 0).
464
488
465
489
References
466
490
----------
0 commit comments