gwin.models package¶
Submodules¶
Module contents¶
This package provides classes and functions for evaluating Bayesian statistics assuming various noise models.
-
class
gwin.models.CallModel(model, callstat, return_all_stats=True)[source]¶ Bases:
objectWrapper class for calling models from a sampler.
This class can be called like a function, with the parameter values to evaluate provided as a list in the same order as the model’s
variable_params. In that case, the model is updated with the provided parameters and then thecallstatretrieved. Ifreturn_all_statsis set toTrue, then all of the stats specified by the model’sdefault_statswill be returned as a tuple, in addition to the stat value.The model’s attributes are promoted to this class’s namespace, so that any attribute and method of
modelmay be called directly from this class.This class must be initalized prior to the creation of a
Poolobject.Parameters: Examples
Create a wrapper around an instance of the
TestNormalmodel, with thecallstatset tologposterior:>>> from gwin.models import TestNormal, CallModel >>> model = TestNormal(['x', 'y']) >>> call_model = CallModel(model, 'logposterior')
Now call on a set of parameter values:
>>> call_model([0.1, -0.2]) (-1.8628770664093453, (0.0, 0.0, -1.8628770664093453))
Note that a tuple of all of the model’s
default_statswere returned in addition to thelogposteriorvalue. We can shut this off by togglingreturn_all_stats:>>> call_model.return_all_stats = False >>> call_model([0.1, -0.2]) -1.8628770664093453
Attributes of the model can be called from the call model. For example:
>>> call_model.variable_params ('x', 'y')
-
gwin.models.read_from_config(cp, **kwargs)[source]¶ Initializes a model from the given config file.
The section must have a
nameargument. The name argument corresponds to the name of the class to initialize.Parameters: - cp (WorkflowConfigParser) – Config file parser to read.
- **kwargs – All other keyword arguments are passed to the
from_configmethod of the class specified by the name argument.
Returns: The initialized model.
Return type: cls