Probability density function.
194492
def _pdf(self, x, dist, cache):
        """"""
        return evaluation.evaluate_density(
            dist, numpy.arcsinh(x), cache=cache)/numpy.sqrt(1+x*x)
119546
def weighted_choice(self, probabilities, key):
        """"""

        total = sum(x[0] for x in probabilities)
        choice = total * self._random(key)

        for probability, option in probabilities:
            choice -= probability
            if choice <= 0:
                return option
763014
def Kdiag(self, X):
        """"""
        ret = np.empty(X.shape[0])
        ret[:] = self.variance
        return ret
519454
def noise_gaussian(self, mean, std):
        """"""
        assert std > 0
        ng = self.sym.sym('ng_{:d}'.format(len(self.scope['ng'])))
        self.scope['ng'].append(ng)
        return mean + std*ng
1161175
def deltaW(N, m, h):
    
    return np.random.normal(0.0, np.sqrt(h), (N, m))
587102
def mixed_density(qubits: Union[int, Qubits]) -> Density:
    """"""
    N, qubits = qubits_count_tuple(qubits)
    matrix = np.eye(2**N) / 2**N
    return Density(matrix, qubits)
1119665
def density(self, *args):
        
        M = self.mass(*args) * MSUN
        V = 4./3 * np.pi * (self.radius(*args) * RSUN)**3
        return  M/V
1067128
def probability_density(self, X):
        
        self.check_fit()

        # make cov positive semi-definite
        covariance = self.covariance * np.identity(self.covariance.shape[0])
        return stats.multivariate_normal.pdf(X, cov=covariance)
1209201
def _rndPointDisposition(dx, dy):
        """"""
        x = int(random.uniform(-dx, dx))
        y = int(random.uniform(-dy, dy))
        return (x, y)
457364
def somenan(self, x, fun, p=0.1):
        """"""
        if np.random.rand(1) < p:
            return np.NaN
        else:
            return fun(x)
814679
def _log_multivariate_normal_density_diag(X, means, covars):
    """"""
    n_samples, n_dim = X.shape
    lpr = -0.5 * (n_dim * np.log(2 * np.pi) + np.sum(np.log(covars), 1)
                  + np.sum((means ** 2) / covars, 1)
                  - 2 * np.dot(X, (means / covars).T)
                  + np.dot(X ** 2, (1.0 / covars).T))
    return lpr
797196
def _density_par(self,dangle,tdisrupt=None):
        """"""
        if tdisrupt is None: tdisrupt= self._tdisrupt
        dOmin= dangle/tdisrupt
        # Normalize to 1 close to progenitor
        return 0.5\
            *(1.+special.erf((self._meandO-dOmin)\
                                 /numpy.sqrt(2.*self._sortedSigOEig[2])))
551194
def cumulative_distribution(self, X):
        
        self.check_fit()

        # Wrapper for pdf to accept vector as args
        def func(*args):
            return self.probability_density(list(args))

        # Lower bound for integral, to split significant part from tail
        lower_bound = self.get_lower_bound()

        ranges = [[lower_bound, val] for val in X]
        return integrate.nquad(func, ranges)[0]
1180377
def function(self,p):
        """"""
        return 0.5 + 0.5*np.sin(p.frequency*2*pi*self.pattern_y + p.phase)
546408
def _pdf(self, phi):
        
        pdf = np.inner(self._vn, np.cos(np.outer(phi, self._n)))
        pdf *= 2.
        pdf += 1.

        return pdf
709417
def _optm(x, alpha, mu, sigma):
    '''
    '''
    return ss.skewnorm.pdf(x, alpha, mu, sigma)
1249660
def density(self, r, rho0, gamma):
        
        rho = rho0 / r**gamma
        return rho