Exemplo n.º 1
0
    def testRandom(self):

        pdf = Normal(4, 2)
        data = pdf.random(100000)

        self.assertAlmostEqual(numpy.mean(data), pdf.mu, delta=0.05)
        self.assertAlmostEqual(numpy.std(data), pdf.sigma, delta=0.05)
Exemplo n.º 2
0
 def testRandom(self):
     
     pdf = Normal(4, 2)
     data = pdf.random(100000)
      
     self.assertAlmostEqual(numpy.mean(data), pdf.mu, delta=0.05)
     self.assertAlmostEqual(numpy.std(data), pdf.sigma, delta=0.05)    
Exemplo n.º 3
0
    def testSampleFromHistogram(self):
        mu = 5.
        sigma = 1.

        normal = Normal(mu, sigma)

        x = normal.random(10000)
        hx, p = density(x, 100)

        samples = hx[sample_from_histogram(p, n_samples=10000)]

        self.assertAlmostEqual(mu, numpy.mean(samples), delta=0.5)
        self.assertAlmostEqual(sigma, numpy.std(samples), delta=0.5)
Exemplo n.º 4
0
    def testSampleFromHistogram(self):
        mu = 5.
        sigma = 1.

        normal = Normal(mu, sigma)

        x = normal.random(10000)
        hx, p = density(x, 100)

        samples = hx[sample_from_histogram(p, n_samples=10000)]

        self.assertAlmostEqual(mu, numpy.mean(samples), delta=0.5)
        self.assertAlmostEqual(sigma, numpy.std(samples), delta=0.5)