

def __init__(self, K, pi=None, psi=None, mu=None, Sigma=None):
    '\n        Create a PGMultinomial distribution with mean and covariance for psi.\n\n        :param K:       Dimensionality of the multinomial distribution\n        :param pi:      Multinomial probability vector (must sum to 1)\n        :param psi:     Transformed multinomial probability vector\n        :param mu:      Mean of \\psi\n        :param Sigma:   Covariance of \\psi\n        '
    assert (isinstance(K, int) and (K >= 2)), 'K must be an integer >= 2'
    self.K = K
    assert ((pi is not None) or (psi is not None) or (None not in (mu, Sigma))), 'pi, psi, or (mu and Sigma) must be specified'
    if (pi is not None):
        assert (isinstance(pi, np.ndarray) and (pi.shape == (K,)) and np.allclose(pi.sum(), 1.0)), 'Pi must be a normalized length-K vector'
        self.pi = pi
    if (psi is not None):
        assert (isinstance(psi, np.ndarray) and (psi.shape == ((K - 1),))), 'Psi must be a length-K vector of reals'
        self.psi = psi
    if (None not in (mu, Sigma)):
        assert (isinstance(mu, np.ndarray) and (mu.shape == (K,))), 'Mu must be a length-K vector'
        assert (isinstance(Sigma, np.ndarray) and (Sigma.shape == (K, K))), 'Sigma must be a KxK Covariance matrix'
        self.mu = mu
        self.Sigma = Sigma
        self.Lambda = np.linalg.inv(Sigma)
        if ((psi is None) and (pi is None)):
            self.psi = np.random.multivariate_normal(self.mu, self.Sigma)
    self.ppgs = initialize_polya_gamma_samplers()
    self.omega = np.ones(self.K)
    self.rho = np.zeros(self.K)

dataset/ETHPy150Open HIPS/pgmult/pgmult/distributions.py PGLogisticNormalMultinomial.__init__/original