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")
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)
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)
def test_basic(self): interface.mcmc(data)
def test_stepwidth(self): interface.mcmc(data, nsamples=25, stepwidths=[0.1, 0.2, 0.3])
def test_nafc(self): interface.mcmc(data, nsamples=25, nafc=23)
def test_core(self): interface.mcmc(data, nsamples=25, core='ab')
def test_prior(self): priors = ('Gauss(0,10)', 'Gamma(2,3)', 'Uniform(1,5)') interface.mcmc(data, nsamples=25, priors=priors)
def test_nafc(self): interface.mcmc(data,nsamples=25, nafc=23)
def test_nsamples(self): interface.mcmc(data, nsamples=666)
def test_start(self): interface.mcmc(data,nsamples=25, start=[0.1,0.2,0.3])
def test_sigmoid(self): interface.mcmc(data, nsamples=25, sigmoid='gumbel_r')
def test_nsamples(self): interface.mcmc(data,nsamples=666)
def test_start(self): interface.mcmc(data, nsamples=25, start=[0.1, 0.2, 0.3])
def test_sigmoid(self): interface.mcmc(data,nsamples=25, sigmoid='gumbel_r')
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