gwin.models.analytic module

This modules provides models that have analytic solutions for the log likelihood.

class gwin.models.analytic.TestEggbox(variable_params, **kwargs)[source]

Bases: gwin.models.base.BaseModel

The test distribution is an ‘eggbox’ function:

\[\log \mathcal{L}(\Theta) = \left[ 2+\prod_{i=1}^{n}\cos\left(\frac{\theta_{i}}{2}\right)\right]^{5}\]

The number of dimensions is set by the number of variable_params that are passed.

Parameters:
  • variable_params ((tuple of) string(s)) – A tuple of parameter names that will be varied.
  • **kwargs – All other keyword arguments are passed to BaseModel.
name = 'test_eggbox'
class gwin.models.analytic.TestNormal(variable_params, mean=None, cov=None, **kwargs)[source]

Bases: gwin.models.base.BaseModel

The test distribution is an multi-variate normal distribution.

The number of dimensions is set by the number of variable_params that are passed. For details on the distribution used, see scipy.stats.multivariate_normal.

Parameters:
  • variable_params ((tuple of) string(s)) – A tuple of parameter names that will be varied.
  • mean (array-like, optional) – The mean values of the parameters. If None provide, will use 0 for all parameters.
  • cov (array-like, optional) – The covariance matrix of the parameters. If None provided, will use unit variance for all parameters, with cross-terms set to 0.
  • **kwargs – All other keyword arguments are passed to BaseModel.

Examples

Create a 2D model with zero mean and unit variance:

>>> m = TestNormal(['x', 'y'])

Set the current parameters and evaluate the log posterior:

>>> m.update(x=-0.2, y=0.1)
>>> m.logposterior
-1.8628770664093453

See the current stats that were evaluated:

>>> m.current_stats
{'logjacobian': 0.0, 'loglikelihood': -1.8628770664093453, 'logprior': 0.0}
name = 'test_normal'
class gwin.models.analytic.TestRosenbrock(variable_params, **kwargs)[source]

Bases: gwin.models.base.BaseModel

The test distribution is the Rosenbrock function:

\[\log \mathcal{L}(\Theta) = -\sum_{i=1}^{n-1}[ (1-\theta_{i})^{2}+100(\theta_{i+1} - \theta_{i}^{2})^{2}]\]

The number of dimensions is set by the number of variable_params that are passed.

Parameters:
  • variable_params ((tuple of) string(s)) – A tuple of parameter names that will be varied.
  • **kwargs – All other keyword arguments are passed to BaseModel.
name = 'test_rosenbrock'
class gwin.models.analytic.TestVolcano(variable_params, **kwargs)[source]

Bases: gwin.models.base.BaseModel

The test distribution is a two-dimensional ‘volcano’ function:

\[\Theta = \sqrt{\theta_{1}^{2} + \theta_{2}^{2}} \log \mathcal{L}(\Theta) = 25\left(e^{\frac{-\Theta}{35}} + \frac{1}{2\sqrt{2\pi}} e^{-\frac{(\Theta-5)^{2}}{8}}\right)\]
Parameters:
  • variable_params ((tuple of) string(s)) – A tuple of parameter names that will be varied. Must have length 2.
  • **kwargs – All other keyword arguments are passed to BaseModel.
name = 'test_volcano'