Log PDF for Inverse Gamma prior

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

        Returns
        ----------
        - log(p(x))
189515
def logpdf(self, x):
        
        if self.transform is not None:
            x = self.transform(x)       
        return (-self.alpha-1)*np.log(x) - (self.beta/float(x))
698732
def lnlike(self, X):
        
        return -3.5*np.log(self._interpolant(X[0], X[1], grid=False))
1305759
public static BigFloat log(BigFloat x) {
		BigFloat temp = logSpecial(x);
		return temp != null ? temp : x.context.valueOf(BigDecimalMath.log(x.value, x.context.mathContext));
	}
134078
def _loglikelihood(params, x, tx, T):
        warnings.simplefilter(action="ignore", category=FutureWarning)

        """"""
        alpha, beta, gamma, delta = params

        betaln_ab = betaln(alpha, beta)
        betaln_gd = betaln(gamma, delta)

        A = betaln(alpha + x, beta + T - x) - betaln_ab + betaln(gamma, delta + T) - betaln_gd

        B = 1e-15 * np.ones_like(T)
        recency_T = T - tx - 1

        for j in np.arange(recency_T.max() + 1):
            ix = recency_T >= j
            B = B + ix * betaf(alpha + x, beta + tx - x + j) * betaf(gamma + 1, delta + tx + j)

        B = log(B) - betaln_gd - betaln_ab
        return logaddexp(A, B)
675731
def bayesianUpperLimit(self, alpha, steps=1.e5, plot=False):
        
        x_dense, y_dense = self.densify()
        y_dense -= np.max(y_dense) # Numeric stability
        f = scipy.interpolate.interp1d(x_dense, y_dense, kind='linear')
        x = np.linspace(0., np.max(x_dense), steps)
        pdf = np.exp(f(x) / 2.)
        cut = (pdf / np.max(pdf)) > 1.e-10
        x = x[cut]
        pdf = pdf[cut]
        #pdf /= pdf[0]
        #forbidden = np.nonzero(pdf < 1.e-10)[0]
        #if len(forbidden) > 0:
        #    index = forbidden[0] # Numeric stability
        #    x = x[0: index]
        #    pdf = pdf[0: index]
        cdf = np.cumsum(pdf)
        cdf /= cdf[-1]
        cdf_reflect = scipy.interpolate.interp1d(cdf, x)

        return cdf_reflect(alpha)
324454
def black_box_variational_inference(logprob, D, num_samples):
    """"""

    def unpack_params(params):
        # Variational dist is a diagonal Gaussian.
        mean, log_std = params[:D], params[D:]
        return mean, log_std

    def gaussian_entropy(log_std):
        return 0.5 * D * (1.0 + np.log(2*np.pi)) + np.sum(log_std)

    rs = npr.RandomState(0)
    def variational_objective(params, t):
        """Provides a stochastic estimate of the variational lower bound."""
        mean, log_std = unpack_params(params)
        samples = rs.randn(num_samples, D) * np.exp(log_std) + mean
        lower_bound = gaussian_entropy(log_std) + np.mean(logprob(samples, t))
        return -lower_bound

    gradient = grad(variational_objective)

    return variational_objective, gradient, unpack_params
851071
def data_log_likelihood(self, successes, trials, beta):
        ''''''
        return binom.logpmf(successes, trials, 1.0 / (1 + np.exp(-beta))).sum()
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
339027
def neg_log_likelihood(self, x, standard=False):
        
        x_reshape = tf.reshape(x, [self.batch_size, self.eq_samples, self.iw_samples, self.num_latent])
        c = - 0.5 * math.log(2 * math.pi)
        if standard is False:
            density = c - tf.log(self.std) - (x_reshape - self.mu) ** 2 / (2 * self.std**2)
        else:
            density = c - (x_reshape - self.mu) ** 2 / 2
        # sum over all importance weights. average over all eq_samples
        return tf.reduce_mean(tf.reduce_sum(-density, axis=2), axis=(1, 2))
599754
def log(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_log,
        (BigFloat._implicit_convert(x),),
        context,
    )
387097
def log_likelihood(self):
        
        if self._log_likelihood is None:
            self._log_likelihood = logpdf(x=self.y, cov=self.S)
        return self._log_likelihood
281874
def log10norm(x, mu, sigma=1.0):
    
    return stats.lognorm(sigma * np.log(10), scale=mu).pdf(x)
69179
def _get_log_prior_cl_func(self):
        
        return SimpleCLFunction.from_string('''
            mot_float_type _computeLogPrior(local const mot_float_type* x, void* data){
                return ''' + self._log_prior_func.get_cl_function_name() + '''(x, data);
            }
        ''', dependencies=[self._log_prior_func])
684831
def log_prior(self):
        """"""
        if self.priors.size == 0:
            return 0.
        x = self.param_array
        # log densities
        log_p = reduce(lambda a, b: a + b, (p.lnpdf(x[ind]).sum() for p, ind in self.priors.items()), 0)

        #account for the transformation by evaluating the log Jacobian (where things are transformed)
        log_j = 0.
        priored_indexes = np.hstack([i for p, i in self.priors.items()])
        for c,j in self.constraints.items():
            if not isinstance(c, Transformation):continue
            for jj in j:
                if jj in priored_indexes:
                    log_j += c.log_jacobian(x[jj])
        return log_p + log_j
297607
def lognormcdf(x, mu, tau):
    """"""
    x = np.atleast_1d(x)
    return np.array(
        [0.5 * (1 - flib.derf(-(np.sqrt(tau / 2)) * (np.log(y) - mu))) for y in x])
1004974
def gamma(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_gamma,
        (BigFloat._implicit_convert(x),),
        context,
    )
460508
private static function logStirlingApproximation($x) {
		$t = 0.5*log(2*pi()) - 0.5*log($x) + $x*(log($x))-$x;

		$x2 = $x * $x;
		$x3 = $x2 * $x;
		$x4 = $x3 * $x;

		$err_term = log(1 + (1.0/(12*$x)) + (1.0/(288*$x2)) - (139.0/(51840*$x3))
			- (571.0/(2488320*$x4)));

		$res = $t + $err_term;
		return $res;
	}