PDF for Normal prior

        Parameters
        ----------
        mu : float
            Latent variable for which the prior is being formed over

        Returns
        ----------
        - p(mu)
969807
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)             
        return (1.0/float(self.sigma0))*np.exp(-(0.5*(mu-self.mu0)**2)/float(self.sigma0**2))
116787
def rtruncated_normal(mu, tau, a=-np.inf, b=np.inf, size=None):
    

    sigma = 1. / np.sqrt(tau)
    na = utils.normcdf((a - mu) / sigma)
    nb = utils.normcdf((b - mu) / sigma)

    # Use the inverse CDF generation method.
    U = np.random.mtrand.uniform(size=size)
    q = U * nb + (1 - U) * na
    R = utils.invcdf(q)

    # Unnormalize
    return R * sigma + mu
1032053
def params(self):
        
        p = CombinedBounds(self.k.params, self.noise_k.params)
        if self.mu is not None:
            p = CombinedBounds(p, self.mu.params)
        return p
265147
def mle_parameter_estimate(self):
        
        res = self.pst.res
        assert res is not None
        # build the prior expectation parameter vector
        prior_expt = self.pst.parameter_data.loc[:,["parval1"]].copy()
        islog = self.pst.parameter_data.partrans == "log"
        prior_expt.loc[islog] = prior_expt.loc[islog].apply(np.log10)
        prior_expt = Matrix.from_dataframe(prior_expt)
        prior_expt.col_names = ["prior_expt"]
        # build the residual vector
        res_vec = Matrix.from_dataframe(res.loc[:,["residual"]])

        # calc posterior expectation
        upgrade = self.mle_covariance * self.jco.T * res_vec
        upgrade.col_names = ["prior_expt"]
        post_expt = prior_expt + upgrade

        # post processing - back log transform
        post_expt = pd.DataFrame(data=post_expt.x,index=post_expt.row_names,
                                 columns=["post_expt"])
        post_expt.loc[islog,:] = 10.0**post_expt.loc[islog,:]
        return post_expt
202751
def ln_norm(x, mu, sigma=1.0):
    
    return np.log(stats.norm(loc=mu, scale=sigma).pdf(x))
403462
def underlying_likelihood(self, binary_outcomes, modelparams, expparams):
        
        original_mps = modelparams[..., self._orig_mps_slice]
        return self.underlying_model.likelihood(binary_outcomes, original_mps, expparams)
286841
def inverse_guass(self, mu: float, sigma: float) -> float:
        
        return float(
            lib.TCOD_random_get_gaussian_double_inv(self.random_c, mu, sigma)
        )
941429
def q_prior(q, m=1, gamma=0.3, qmin=0.1):
    
    if q < qmin or q > 1:
        return 0
    C = 1/(1/(gamma+1)*(1 - qmin**(gamma+1)))
    return C*q**gamma
719203
public static double pdf(double x, double mu, double sigma, double xi) {
    x = (x - mu) / sigma;
    // Check support:
    if(x < 0 || (xi < 0 && x > -1. / xi)) {
      return 0.;
    }
    return ((xi == 0) ? 1. : FastMath.pow(1 + xi * x, -1 / xi - 1)) / sigma;
  }
252498
public static double pdf(double x, double mu, double sigma) {
    if(x <= 0.) {
      return 0.;
    }
    final double xrel = (FastMath.log(x) - mu) / sigma;
    return 1 / (MathUtil.SQRTTWOPI * sigma * x) * FastMath.exp(-.5 * xrel * xrel);
  }
405507
def logpdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)     
        if mu < self.lower and self.lower is not None:
            return -10.0**6
        elif mu > self.upper and self.upper is not None:
            return -10.0**6
        else:
            return -np.log(float(self.sigma0)) - (0.5*(mu-self.mu0)**2)/float(self.sigma0**2)
780473
def pdf_new(self, x, mu, sigma, skw):
        
        if skw > 1 or skw < -1:
            print("skewness %s out of range" % skw)
            skw = 1.
        e, w, a = self.map_mu_sigma_skw(mu, sigma, skw)
        pdf = self.pdf(x, e, w, a)
        return pdf
420538
def construct_wishart(self,v,X):
        
        self.adjust_prior(list(range(int((len(self.latent_variables.z_list)-self.ylen-(self.ylen**2-self.ylen)/2)),
            int(len(self.latent_variables.z_list)))), fam.InverseWishart(v,X))
1348769
def pdf(self, X):
                      
        return invwishart.pdf(X, df=self.v, scale=self.Psi)
1267629
def log_uniform_prior(value, umin=0, umax=None):
    
    if value > 0 and value >= umin:
        if umax is not None:
            if value <= umax:
                return 1 / value
            else:
                return -np.inf
        else:
            return 1 / value
    else:
        return -np.inf
1096481
def _getp(self):
        
        if self._p is not None:
            return self._p
        # buf = [y,prior]; D[a,i] = dp[a]/dbuf[i]
        pmean = _gvar.mean(self.palt).flat
        buf = (
            self.y.flat if self.prior is None else
            numpy.concatenate((self.y.flat, self.prior.flat))
            )
        D = numpy.zeros((self.cov.shape[0], len(buf)), float)
        for i, chivw_i in enumerate(self._chivw(_gvar.valder(pmean))):
            for a in range(D.shape[0]):
                D[a, i] = chivw_i.dotder(self.cov[a])

        # p[a].mean=pmean[a]; p[a].der[j] = sum_i D[a,i]*buf[i].der[j]
        p = []
        for a in range(D.shape[0]): # der[a] = sum_i D[a,i]*buf[i].der
            p.append(_gvar.gvar(pmean[a], _gvar.wsum_der(D[a], buf),
                     buf[0].cov))
        self._p = _reformat(self.p0, p)
        return self._p
1190905
def lnprior(pars):
    
    # Limit norm and B to be positive
    logprob = (
        naima.uniform_prior(pars[0], 0.0, np.inf)
        + naima.uniform_prior(pars[1], -1, 5)
        + naima.uniform_prior(pars[3], 0, np.inf)
    )

    return logprob