Skip to content

Commit 3fd1cc7

Browse files
committed
docstrings
1 parent 4f56c2a commit 3fd1cc7

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

pymc_extras/distributions/discrete.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,15 @@ def rng_fn(cls, rng, alpha, beta, size):
433433
class ShiftedBetaGeometric(Discrete):
434434
r"""Shifted Beta-Geometric distribution.
435435
436-
This distribution is a flexible alternative to the Geometric distribution for the number of trials until a
437-
discrete event, and can be extended to support static and time-varying covariates.
436+
This mixture distribution extends the Geometric distribution for the number of trials until a discrete event
437+
to support heterogeneity across observations.
438438
439439
Hardie and Fader describe this distribution with the following PMF and survival functions in [1]_:
440440
441441
.. math::
442-
\mathbb{P}T=t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t-1)})^{r} - (\frac{\alpha}{\alpha+C(t)})^{r} \\
442+
\mathbb{P}T=t|\alpha,\beta) = (\frac{B(\alpha+1,\beta+t-1)}{B(\alpha,\beta}),t=1,2,... \\
443443
\begin{align}
444-
\mathbb{S}(t|r,\alpha,\beta;Z(t)) = (\frac{\alpha}{\alpha+C(t)})^{r} \\
444+
\mathbb{S}(t|\alpha,\beta) = (\frac{B(\alpha,\beta+t)}{B(\alpha,\beta}),t=1,2,... \\
445445
\end{align}
446446
447447
.. plot::
@@ -450,14 +450,15 @@ class ShiftedBetaGeometric(Discrete):
450450
import matplotlib.pyplot as plt
451451
import numpy as np
452452
import scipy.stats as st
453+
from scipy.special import beta
453454
import arviz as az
454455
plt.style.use('arviz-darkgrid')
455456
t = np.arange(1, 11)
456457
alpha_vals = [1., 1., 2., 2.]
457-
r_vals = [.1, .25, .5, 1.]
458-
for alpha, r in zip(alpha_vals, r_vals):
459-
pmf = (alpha/(alpha + t - 1))**r - (alpha/(alpha+t))**r
460-
plt.plot(t, pmf, '-o', label=r'$\alpha$ = {}, $r$ = {}'.format(alpha, r))
458+
beta_vals = [.1, .25, .5, 1.]
459+
for alpha, _beta in zip(alpha_vals, beta_vals):
460+
pmf = beta(alpha + 1, beta + t - 1) / beta(alpha, beta)
461+
plt.plot(t, pmf, '-o', label=r'$\alpha$ = {}, $beta$ = {}'.format(alpha, beta))
461462
plt.xlabel('t', fontsize=12)
462463
plt.ylabel('p(t)', fontsize=12)
463464
plt.legend(loc=1)
@@ -469,18 +470,16 @@ class ShiftedBetaGeometric(Discrete):
469470
470471
Parameters
471472
----------
472-
r : tensor_like of float
473-
Shape parameter (r > 0).
474473
alpha : tensor_like of float
475474
Scale parameter (alpha > 0).
476-
time_covariate_vector : tensor_like of float
477-
Vector containing dot products of time-varying covariates and coefficients.
475+
beta : tensor_like of float
476+
Scale parameter (beta > 0).
478477
479478
References
480479
----------
481-
.. [1] Fader, Peter & G. S. Hardie, Bruce (2020).
482-
"Incorporating Time-Varying Covariates in a Simple Mixture Model for Discrete-Time Duration Data."
483-
https://www.brucehardie.com/notes/037/time-varying_covariates_in_BG.pdf
480+
.. [1] Fader, P. S., & Hardie, B. G. (2007). How to project customer retention.
481+
Journal of Interactive Marketing, 21(1), 76-90.
482+
https://faculty.wharton.upenn.edu/wp-content/uploads/2012/04/Fader_hardie_jim_07.pdf
484483
"""
485484

486485
rv_op = sbg

0 commit comments

Comments
 (0)