How to use the pymc.deterministic function in pymc

To help you get started, we’ve selected a few pymc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aflaxman / gbd / consistent_model.py View on Github external
    @mc.deterministic
    def mu_age_p(logit_C0=logit_C0,
                 i=rate['i']['mu_age'],
                 r=rate['r']['mu_age'],
                 f=rate['f']['mu_age']):

        # for acute conditions, it is silly to use ODE solver to
        # derive prevalence, and it can be approximated with a simple
        # transformation of incidence
        if r.min() > 5.99:
            return i / (r + m_all + f)
        
        C0 = mc.invlogit(logit_C0)

        x = pl.hstack((i, r, f, 1-C0, C0))
        y = fun.forward(0, x)
github aflaxman / gbd / ism.py View on Github external
    @mc.deterministic
    def mu_age_m_with(m=rate['m']['mu_age'], f=rate['f']['mu_age']):
        return m+f
    m_with = age_specific_rate(model, 'm_with',
github astroML / astroML / book_figures / chapter5 / fig_cauchy_mcmc.py View on Github external
@pymc.deterministic
def gamma(log_gamma=log_gamma):
    return np.exp(log_gamma)
github aflaxman / gbd / space_time_model / model.py View on Github external
    @mc.deterministic
    def data_predicted(param_predicted=param_predicted, tau=tau):
        return mc.rnormal(param_predicted, tau)
    predicted = data_predicted
github aflaxman / gbd / book / binomial_model.py View on Github external
@mc.deterministic
def pred(pi=pi):
    return mc.rbinomial(n, pi)
github aflaxman / gbd / dismod3 / logit_normal_model.py View on Github external
    @mc.deterministic(name='dispersion_%s' % key)
    def sigma(log_sigma=log_sigma):
        return np.exp(log_sigma)
    # TODO: replace this potential in the generate_prior_potentials function if confidence is set
github pymc-devs / pymc3 / pymc / gp / PyMC_objects.py View on Github external
        @pm.deterministic
        def obs_V(obs_V=obs_V, obs_mesh = obs_mesh):
            return np.resize(obs_V, obs_mesh.shape[0])
github aflaxman / gbd / dismod3 / utils.py View on Github external
    @mc.deterministic(name='%s_w_bounds'%rate_vars['rate_stoch'].__name__)
    def mu_bounded(mu=rate_vars['rate_stoch'], bounds_func=rate_vars['bounds_func']):
        return bounds_func(mu, pl.arange(101))  # FIXME: don't hardcode age range
    rate_vars['unbounded_rate'] = rate_vars['rate_stoch']
github aflaxman / gbd / rate_model.py View on Github external
    @mc.deterministic(name='p_pred_%s'%name)
    def p_pred(pi=pi, n=n_nonzero):
        return mc.rbinomial(n, pi+1.e-9) / (1.*n)
github aflaxman / gbd / dismod3 / generic_disease_model.py View on Github external
    @mc.deterministic(name=key % 'bins')
    def SCpm(SC_0=SC_0, i=i, r=r, f=f, m_all_cause=m_all_cause, age_mesh=dm.get_param_age_mesh()):
        SC = pl.zeros([2, len(age_mesh)])
        p = pl.zeros(len(age_mesh))
        m = pl.zeros(len(age_mesh))
        
        SC[:,0] = SC_0
        p[0] = SC_0[1] / (SC_0[0] + SC_0[1])
        m[0] = dismod3.utils.trim(m_all_cause[age_mesh[0]] - f[age_mesh[0]] * p[0],
                                  .1*m_all_cause[age_mesh[0]],
                                  1-dismod3.settings.NEARLY_ZERO)  # trim m[0] to avoid numerical instability

        for ii, a in enumerate(age_mesh[:-1]):
            A = pl.array([[-i[a]-m[ii], r[a]           ],
                          [ i[a]     , -r[a]-m[ii]-f[a]]]) * (age_mesh[ii+1] - age_mesh[ii])

            SC[:,ii+1] = pl.dot(scipy.linalg.expm(A), SC[:,ii])

pymc

Probabilistic Programming in Python: Bayesian Modeling and Probabilistic Machine Learning with PyTensor

Apache-2.0
Latest version published 5 days ago

Package Health Score

93 / 100
Full package analysis