Ejemplo n.º 1
0
    def check_probability(self, model):
        samples_count = 100
        components_count = model.GetNumberOfPrincipalComponents()
        for _ in range(0, samples_count):
            coeffs = randn(components_count)
            s = model.DrawSample(coeffs)
            p = model.ComputeProbability(s)

            # as the distribution we are looking for is just a standard mv normal, all the
            # components are independent. We can thus use a 1d normal distribution to compute the
            # probability of the full pdf.
            p_with_spicy = 1
            for c in coeffs:
                p_with_spicy *= normdist(0, 1).pdf(c)
            self.assertTrue(p, p_with_spicy)
Ejemplo n.º 2
0
    def testProbabilityOfDatasetPlausibility(self):
        num_samples = 100
        nComps = self.model.GetNumberOfPrincipalComponents()
        p_mean = self.model.ComputeProbability(self.model.DrawMean())
        for i in xrange(0, num_samples):
            coeffs = randn(nComps)
            s = self.model.DrawSample(coeffs)
            p = self.model.ComputeProbability(s)

            # as the distribution we are looking for is just a standard mv normal, all the
            # components are independent. We can thus use a 1d normal distribution to compute the
            # probability of the full pdf.
            pScipy = 1
            for c in coeffs:
                pScipy *= normdist(0, 1).pdf(c)
            self.assertTrue(p, pScipy)
Ejemplo n.º 3
0
    def testProbabilityOfDatasetPlausibility(self):
        num_samples = 100
        nComps = self.model.GetNumberOfPrincipalComponents()
        p_mean = self.model.ComputeProbability(self.model.DrawMean())
        for i in xrange(0, num_samples):
            coeffs = randn(nComps)
            s = self.model.DrawSample(coeffs)
            p = self.model.ComputeProbability(s)

            # as the distribution we are looking for is just a standard mv normal, all the
            # components are independent. We can thus use a 1d normal distribution to compute the
            # probability of the full pdf.
            pScipy = 1;
            for c in coeffs:
                pScipy *= normdist(0, 1).pdf(c)
            self.assertTrue(p, pScipy)