예제 #1
0
 def test_alternate_samplers(self):
     # this used to fail for psipy, since it does not support alternative
     # samplers
     interface.mcmc(data, nsamples=25, sampler="MetropolisHastings")
     interface.mcmc(data, nsamples=25, sampler="GenericMetropolis")
     self.assertRaises(sfu.PsignifitException, interface.mcmc, data,
             sampler="DoesNotExist")
예제 #2
0
 def test_alternate_samplers(self):
     # this used to fail for psipy, since it does not support alternative
     # samplers
     interface.mcmc(data, nsamples=25, sampler="MetropolisHastings")
     interface.mcmc(data, nsamples=25, sampler="GenericMetropolis")
     self.assertRaises(sfu.PsignifitException,
                       interface.mcmc,
                       data,
                       sampler="DoesNotExist")
예제 #3
0
 def test_old_doctest(self):
     x = [float(2*k) for k in xrange(6)]
     k = [34,32,40,48,50,48]
     n = [50]*6
     d = [[xx,kk,nn] for xx,kk,nn in zip(x,k,n)]
     priors = ('Gauss(0,1000)','Gauss(0,1000)','Beta(3,100)')
     stepwidths = (1.,1.,0.01)
     sfr.setSeed(1)
     (estimates, deviance, posterior_predictive_data,
     posterior_predictive_deviances, posterior_predictive_Rpd,
     posterior_predictive_Rkd, logposterior_ratios, accept_rate) = interface.mcmc(d,nsamples=10000,priors=priors,stepwidths=stepwidths)
     self.assertAlmostEqual( np.mean(estimates[:,0]), 2.5463976926832483)
     self.assertAlmostEqual( np.mean(estimates[:,1]), 7.335732619111738,
             places=3)
예제 #4
0
 def test_old_doctest(self):
     x = [float(2 * k) for k in xrange(6)]
     k = [34, 32, 40, 48, 50, 48]
     n = [50] * 6
     d = [[xx, kk, nn] for xx, kk, nn in zip(x, k, n)]
     priors = ('Gauss(0,1000)', 'Gauss(0,1000)', 'Beta(3,100)')
     stepwidths = (1., 1., 0.01)
     sfr.setSeed(1)
     (estimates, deviance, posterior_predictive_data,
      posterior_predictive_deviances, posterior_predictive_Rpd,
      posterior_predictive_Rkd, logposterior_ratios,
      accept_rate) = interface.mcmc(d,
                                    nsamples=10000,
                                    priors=priors,
                                    stepwidths=stepwidths)
     self.assertAlmostEqual(np.mean(estimates[:, 0]), 2.5463976926832483)
     self.assertAlmostEqual(np.mean(estimates[:, 1]),
                            7.335732619111738,
                            places=3)
예제 #5
0
 def test_basic(self):
     interface.mcmc(data)
예제 #6
0
 def test_basic(self):
     interface.mcmc(data)
예제 #7
0
 def test_stepwidth(self):
     interface.mcmc(data, nsamples=25, stepwidths=[0.1, 0.2, 0.3])
예제 #8
0
 def test_nafc(self):
     interface.mcmc(data, nsamples=25, nafc=23)
예제 #9
0
 def test_core(self):
     interface.mcmc(data, nsamples=25, core='ab')
예제 #10
0
 def test_prior(self):
     priors = ('Gauss(0,10)', 'Gamma(2,3)', 'Uniform(1,5)')
     interface.mcmc(data, nsamples=25, priors=priors)
예제 #11
0
 def test_nafc(self):
     interface.mcmc(data,nsamples=25, nafc=23)
예제 #12
0
 def test_nsamples(self):
     interface.mcmc(data, nsamples=666)
예제 #13
0
 def test_start(self):
     interface.mcmc(data,nsamples=25, start=[0.1,0.2,0.3])
예제 #14
0
 def test_sigmoid(self):
     interface.mcmc(data, nsamples=25, sigmoid='gumbel_r')
예제 #15
0
 def test_stepwidth(self):
     interface.mcmc(data, nsamples=25, stepwidths=[0.1, 0.2, 0.3])
예제 #16
0
 def test_prior(self):
     priors = ('Gauss(0,10)', 'Gamma(2,3)', 'Uniform(1,5)')
     interface.mcmc(data, nsamples=25, priors=priors)
예제 #17
0
 def test_core(self):
     interface.mcmc(data, nsamples=25, core='ab')
예제 #18
0
 def test_nsamples(self):
     interface.mcmc(data,nsamples=666)
예제 #19
0
 def test_start(self):
     interface.mcmc(data, nsamples=25, start=[0.1, 0.2, 0.3])
예제 #20
0
 def test_sigmoid(self):
     interface.mcmc(data,nsamples=25, sigmoid='gumbel_r')
예제 #21
0
def sample ():
    boots = interface.bootstrap ( d, priors=priors, nsamples=1500-2*k )
    mape = interface.mapestimate ( d, priors=priors )
    mcmc = interface.mcmc ( d, start=(4,2,.02), priors=priors, nsamples = 1500-2*k )
    diag = interface.diagnostics ( d, (4,1,.02) )
    return float(os.popen ( "ps -C python -o rss" ).readlines()[1])/1024