How to use the pymc.normal_like 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 PredictiveScienceLab / pysmc / examples / simple_model.py View on Github external
:type mu    :       1D :class:`numpy.ndarray`
        :param sigma:       The standard deviation of each component.
        :type sigma :       1D :class:`numpy.ndarray`
        """
        # Make sure everything is a numpy array
        pi = np.array(pi)
        mu = np.array(mu)
        sigma = np.array(sigma)
        # The number of components in the mixture
        n = pi.shape[0]
        # pymc.normal_like requires the precision not the variance:
        tau = np.sqrt(1. / sigma ** 2)
        # The following looks a little bit awkward because of the need for
        # numerical stability:
        p = np.log(pi)
        p += np.array([pymc.normal_like(value, mu[i], tau[i])
                       for i in range(n)])
        p = math.fsum(np.exp(p))
        # logp should never be negative, but it can be zero...
        if p <= 0.:
            return -np.inf
        return gamma * math.log(p)
github aflaxman / gbd / book / age_patterns.py View on Github external
def data_obs(data_expected=data_expected, value=data):
        return mc.normal_like(value[:,1],
                              data_expected,
                              value[:,2]**-2)
github aflaxman / gbd / rate_model.py View on Github external
def p_obs(value=p, pi=pi, sigma=sigma, s=s):
        return mc.normal_like(value[~i_inf], pi[~i_inf], 1./(sigma**2. + s[~i_inf]**2.))
github armstrtw / pymc_radon / radon_varying_intercept_and_slope.py View on Github external
def y_i(value=y, mu=y_hat, tau=tau_y):
    return pymc.normal_like(value,mu,tau)
github armstrtw / pymc_radon / radon_inv_wishart.py View on Github external
def y_i(value=y, mu=y_hat, tau=tau_y):
    return pymc.normal_like(value,mu,tau)
github aflaxman / gbd / old_src / dismod3 / multiregion_model.py View on Github external
def hier_potential(r1=vars[stoch_key]['rate_stoch'], r2=world_rate,
                           c1=vars[stoch_key]['conf'], c2=world_confidence):
            return mc.normal_like(np.diff(r1) - np.diff(r2), 0., c1 + c2)
        vars[stoch_key]['h_potential'] = hier_potential
github aflaxman / gbd / dismod3 / utils.py View on Github external
        @mc.potential(name='deriv_sign_{%d,%d,%d,%d}^%s' % (deriv, sign, age_start, age_end, str(rate)))
        def deriv_sign_rate(f=rate,
                            age_indices=age_indices,
                            tau=1.e14,
                            deriv=deriv, sign=sign):
            df = pl.diff(f[age_indices], deriv)
            return mc.normal_like(pl.absolute(df) * (sign * df < 0), 0., tau)
        return [deriv_sign_rate]
github pymc-devs / pymc3 / docs / guidecode / modelbuilding.py View on Github external
@pm.observed
@pm.stochastic
def y(value = 1, mu = x, tau = 100):
    return pm.normal_like(value, numpy.sum(mu**2), tau)
github PredictiveScienceLab / pysmc / examples / diffusion_inverse_model.py View on Github external
def sensors(value=data, mu=model_output, tau=tau, gamma=1.):
        """The value of the response at the sensors."""
        return gamma * pymc.normal_like(value, mu=mu, tau=tau)
    return locals()

pymc

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

Apache-2.0
Latest version published 6 days ago

Package Health Score

93 / 100
Full package analysis