Exemplo n.º 1
0
def test_run_pyBAMBI_polychord():
    loglikelihood.called = False
    prior.called = False
    pybambi.run_pyBAMBI(loglikelihood,
                        prior,
                        nDims,
                        nested_sampler='polychord',
                        root='chains/polychord',
                        nlive=50)
    assert (loglikelihood.called is True)
    assert (prior.called is True)
Exemplo n.º 2
0
def test_run_pyBAMBI_polychord():
    loglikelihood.called = False
    prior.called = False
    try:
        os.makedirs('./chains/clusters/')
    except:
        pass
    pybambi.run_pyBAMBI(loglikelihood,
                        prior,
                        nDims,
                        nested_sampler='polychord',
                        root='.chains/polychord',
                        nlive=50)
    assert (loglikelihood.called == True)
    assert (prior.called == True)
    try:
        shutil.rmtree('.chains')
    except:
        pass
Exemplo n.º 3
0
def test_run_pyBAMBI_inputs():
    with pytest.raises(NotImplementedError):
        pybambi.run_pyBAMBI(0, 0, 0, nested_sampler='NAN')

    with pytest.raises(TypeError):
        pybambi.run_pyBAMBI(0, 0, 0, wrong_kwarg='foo')
Exemplo n.º 4
0
from pybambi import run_pyBAMBI

from numpy import pi, log, sqrt
from mpi4py import MPI

nDims = 3


def loglikelihood(theta):
    """ Spherical Gaussian Likelihood """
    sigma = 0.1
    nDims = len(theta)
    logL = -log(2 * pi * sigma * sigma) * nDims / 2.0 - sum(
        (theta / sigma)**2) / 2 + log(2) * nDims
    return logL


def prior(cube):
    """ prior mapping [0,1] -> [-1, 1]"""
    return -1 + 2 * cube


#run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='multinest', nlive=500)
run_pyBAMBI(loglikelihood, prior, nDims, nested_sampler='polychord', nlive=500)
Exemplo n.º 5
0
from pybambi import run_pyBAMBI

from numpy import pi, log

nDims = 3


def loglikelihood(theta):
    """ Spherical Gaussian Likelihood """
    sigma = 0.1
    nDims = len(theta)
    logL = -sum((theta / sigma)**2) / 2
    logL += -log(2 * pi * sigma * sigma) * nDims / 2.0 + log(2) * nDims
    return logL


def prior(cube):
    """ prior mapping [0,1] -> [-1, 1]"""
    return -1 + 2 * cube


run_pyBAMBI(loglikelihood,
            prior,
            nDims,
            nested_sampler='multinest',
            nlive=500,
            learner='keras')