コード例 #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)
コード例 #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)    
コード例 #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)
コード例 #4
0
ファイル: rand.py プロジェクト: jakebarnwell/PythonGenerator
    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)