def prob(self, gauss):
    """Returns the probability of drawing the provided Gaussian from this prior."""
    d = self.mu.shape[0]
    wishart = Wishart(d)
    gaussian = Gaussian(d)
    
    wishart.setDof(self.n)
    wishart.setScale(self.getLambda())
    gaussian.setMean(self.mu)
    gaussian.setPrecision(self.k*gauss.getPrecision())

    return wishart.prob(gauss.getPrecision()) * gaussian.prob(gauss.getMean())
Esempio n. 2
0
    def prob(self, gauss):
        """Returns the probability of drawing the provided Gaussian from this prior."""
        d = self.mu.shape[0]
        wishart = Wishart(d)
        gaussian = Gaussian(d)

        wishart.setDof(self.n)
        wishart.setScale(self.getLambda())
        gaussian.setMean(self.mu)
        gaussian.setPrecision(self.k * gauss.getPrecision())

        return wishart.prob(gauss.getPrecision()) * gaussian.prob(gauss.getMean())
Esempio n. 3
0
    def sample(self):
        """Returns a Gaussian, drawn from this prior."""
        d = self.mu.shape[0]
        wishart = Wishart(d)
        gaussian = Gaussian(d)
        ret = Gaussian(d)

        wishart.setDof(self.n)
        wishart.setScale(self.getLambda())
        ret.setPrecision(wishart.sample())

        gaussian.setPrecision(self.k * ret.getPrecision())
        gaussian.setMean(self.mu)
        ret.setMean(gaussian.sample())

        return ret
Esempio n. 4
0
    def sample(self):
        """Returns a Gaussian, drawn from this prior."""
        d = self.mu.shape[0]
        wishart = Wishart(d)
        gaussian = Gaussian(d)
        ret = Gaussian(d)

        wishart.setDof(self.n)
        wishart.setScale(self.getLambda())
        ret.setPrecision(wishart.sample())

        gaussian.setPrecision(self.k * ret.getPrecision())
        gaussian.setMean(self.mu)
        ret.setMean(gaussian.sample())

        return ret