Skip to content

Instantly share code, notes, and snippets.

@psinger
Created March 18, 2018 13:34
Show Gist options
  • Save psinger/f20945db6eaea674e87380adfda78c87 to your computer and use it in GitHub Desktop.
Save psinger/f20945db6eaea674e87380adfda78c87 to your computer and use it in GitHub Desktop.
import pymc as mc
from scipy.special import zeta
def _model(data, discrete=True, xmin=1.):
alpha = mc.Exponential('alpha', 1. / 1.5)
@mc.stochastic(observed=True)
def custom_stochastic(value=data, alpha=alpha, xmin=xmin, discrete=discrete):
value = value[value >= xmin]
if discrete == True:
return np.sum(np.log(value**-alpha / zeta(alpha,xmin)))
else:
return np.sum(np.log((alpha-1) * xmin**(alpha-1) * value**-alpha))
return locals()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment