Beispiel #1
0
 def __init__(self):
     # we'll use a 2D Gaussian for the likelihood distribution
     self.params = ['x0', 'x1']
     self.mean = numpy.array([2., 5.])
     self.std = numpy.array([1., 2.])
     self.likelihood_dist = stats.norm(loc=self.mean, scale=self.std)
     # we'll just use a uniform prior
     xbnds = Boundaries((-20., 20.))
     ybnds = Boundaries((-40., 40.))
     self.prior_bounds = {'x0': xbnds, 'x1': ybnds}
     self.prior_dist = {
         'x0': stats.uniform(xbnds.lower, abs(xbnds)),
         'x1': stats.uniform(ybnds.lower, abs(ybnds))
     }
Beispiel #2
0
 def __init__(self, lmbda=3):
     # we'll use a Poission distribution for the likelihood
     self.params = ['k']
     self.likelihood_dist = stats.poisson(lmbda)
     # we'll just use a uniform prior
     kmin = 0
     kmax = 10
     self.prior_bounds = {'k': Boundaries((kmin, kmax))}
     self.prior_dist = {'k': stats.randint(kmin, kmax)}
Beispiel #3
0
 def __init__(self, phi0=0., std=1.):
     self.phi0 = phi0
     self.params = ['phi']
     self.std = numpy.array([std])
     # we'll just use a uniform prior
     self.prior_bounds = {'phi': Boundaries((0., 2 * numpy.pi))}
     pmin = self.prior_bounds['phi'].lower
     dp = abs(self.prior_bounds['phi'])
     self.prior_dist = {'phi': stats.uniform(pmin, dp)}
Beispiel #4
0
 def __init__(self, seed=None):
     # we'll use a 2D Gaussian for the likelihood distribution
     self.params = ['x0', 'x1']
     self.mean = numpy.array([2., 5.])
     self.std = numpy.array([1., 2.])
     self.likelihood_dist = stats.norm(loc=self.mean, scale=self.std)
     # we'll just use a uniform prior
     xbnds = Boundaries((-20., 20.))
     ybnds = Boundaries((-40., 40.))
     self.prior_bounds = {'x0': xbnds, 'x1': ybnds}
     self.prior_dist = {
         'x0': stats.uniform(xbnds.lower, abs(xbnds)),
         'x1': stats.uniform(ybnds.lower, abs(ybnds))
     }
     # create an rng for drawing prior samples
     if seed is None:
         seed = MODEL_SEED
     self.rng = numpy.random.default_rng(seed)
Beispiel #5
0
 def __init__(self, lmbda=3, seed=None):
     # we'll use a Poission distribution for the likelihood
     self.params = ['k']
     self.likelihood_dist = stats.poisson(lmbda)
     # we'll just use a uniform prior
     kmin = 0
     kmax = 10
     self.prior_bounds = {'k': Boundaries((kmin, kmax))}
     self.prior_dist = {'k': stats.randint(kmin, kmax)}
     # create an rng for drawing prior samples
     if seed is None:
         seed = MODEL_SEED
     self.rng = numpy.random.default_rng(seed)
Beispiel #6
0
 def __init__(self, phi0=0., std=1., seed=None):
     self.phi0 = phi0
     self.params = ['phi']
     self.std = numpy.array([std])
     # we'll just use a uniform prior
     self.prior_bounds = {'phi': Boundaries((0., 2 * numpy.pi))}
     pmin = self.prior_bounds['phi'].lower
     dp = abs(self.prior_bounds['phi'])
     self.prior_dist = {'phi': stats.uniform(pmin, dp)}
     # create an rng for drawing prior samples
     if seed is None:
         seed = MODEL_SEED
     self.rng = numpy.random.default_rng(seed)
Beispiel #7
0
def get_param_boundaries(params, opts):
    """Gets parameter boundaries for jump proposals.

    The syntax for the options should be ``(min|max)_{param} = value``. Both
    a minimum and maximum should be provided for every parameter in ``params``.
    If the opts are created using ``load_opts``, then the options can be
    formatted as ``(min|max)-{param}``, since that function will turn all ``-``
    to ``_`` in option names.

    Arguments will be popped from the given ``opts`` dictionary.

    Parameters
    ----------
    params : list of str
        List of parameter names to get boundaries for.
    opts : dict
        Dictionary of option -> value that was loaded from a config file
        section.

    Returns
    -------
    dict :
        Dictionary of parameter names -> :py:class:`epsie.proposals.Boundaries`
    """
    boundaries = {}
    for param in params:
        minbound = opts.pop('min_{}'.format(param), None)
        if minbound is None:
            raise ValueError("Must provide a minimum bound for {p}."
                             "Syntax is min_{p} = val".format(p=param))
        maxbound = opts.pop('max_{}'.format(param), None)
        if maxbound is None:
            raise ValueError("Must provide a maximum bound for {p}."
                             "Syntax is max_{p} = val".format(p=param))
        boundaries[param] = Boundaries((float(minbound), float(maxbound)))
    return boundaries