binf.model package¶
Submodules¶
binf.model.errormodels module¶
This module contains interfaces for error models
-
class
binf.model.errormodels.AbstractErrorModel(name='', **args)[source]¶ Bases:
binf.pdf.AbstractBinfPDF-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 35¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
_check_differentiability(**variables)¶ Checks whether this object can be differentiated w.r.t. specific variables
-
_complete_variables(variables)¶ _complete_variables and _reduce_variables so far only work for classes which both inherit from AbstractBinfNamedCallable and can hold parameters (that is, PDFs and models)
-
_delete_variable(name)¶ Removes a variable from the set of registed variables
Parameters: name (str) – name of the variable to be removed
-
_evaluate(**variables)¶ In this method, the actual function evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_evaluate_gradient(**variables)¶ In this method, the actual gradient evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_evaluate_log_prob(**variables)¶ In this method, the actual evaluation of the log-probability takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_get_variables_intersection(test_variables)¶ Returns the intersection of the variables stored in the argument with the set of currently registered variables
-
_register(name)¶ Register a new parameter name.
-
_register_variable(name, differentiable=False)¶ Registers a variable so that later on it can be fixed or checked whether it has been passed to the __call__ method
Parameters:
-
_set(param, value)¶ Update the C{value} of C{param}.
-
_set_original_variables()¶ Stores the original set of named variables this object takes
-
_validate(param, value)¶ Parameter value validation hook. @raise ParameterValueError: on failed validation (value not accepted)
-
clone()¶ Returns an exact copy (same parameters / variables…) of this object
Returns: a copy of this object Return type: AbstractBinfPDF
-
conditional_factory(**fixed_vars)¶ Makes a copy of this object in which one or several variables are set to specific values (on which the new PDF is ‘conditioned’ on)
The ‘conditioning’ must not be taken literally, as no prior probabilities are taken into account. But that doesn’t bother us, as we’re going to MCMC sampling anyways
Parameters: **variables – keyword arguments containg name / value pairs for variables on which this PDF should be conditioned on Returns: PDF object conditioned on the given values Return type: AbstractBinfPDF
-
differentiable_variables¶ Returns the set of currently registered variables this object implements the gradient w.r.t
Returns: set of variables this object can be differentiated w.r.t. Return type: set
-
estimate(data)¶ Estimate and load the parameters of the distribution from sample C{data} using the current L{AbstractEstimator} strategy.
@param data: sample values @type data: array
- @raise NotImplementedError: when no estimator is available for this
- distribution
- @raise IncompatibleEstimatorError: when the current estimator is not
- compatible with this pdf
-
estimator¶
-
evaluate(x)¶ Evaluate the probability of observing values C{x}.
@param x: values @type x: array @rtype: array
-
fix_variables(**fixed_vars)¶ Sets (‘fixes’) specific variables to values given as keyword arguments by removing these variables from the list of registered variables and registering corresponding parameters to this object.
-
get_params()¶
-
gradient(**variables)¶ This function will be called from outside to evaluate the gradient of the function (or a related one, e.g., log-probability) represented by this object
Parameters: **variables – list of variable name / value pairs Returns: gradient of the function represented by this object Return type: numpy.ndarray
-
log_prob(**variables)¶ Evaluates the log-probability of the PDF represented by this object
Parameters: **variables – list of variable name / value pairs Returns: log-probability Return type: float
-
name¶ Returns the name of this object
-
parameters¶ Get a list of all distribution parameter names.
-
random(size=None)¶ Generate random samples from the probability distribution.
@param size: number of values to sample @type size: int
-
set_fixed_variables_from_pdf(pdf)¶ Retrieves fixed variables from another PDF object and fixes the same variables in this object accordingly
Parameters: pdf ( AbstractBinfPDF) – PDF object to retrieve variables to fix from
-
set_params(*values, **named_params)¶
-
update_var_param_types(**values)¶ Updates the dictionary holding the types of registered variables
-
var_param_types¶ Empty by default, but for a conditional PDF to be built, one has to add AbstractParameter subclasses suiting the variables.
-
binf.model.forwardmodels module¶
This module contains interfaces for forward models.
-
class
binf.model.forwardmodels.AbstractForwardModel(name, parameters=[])[source]¶ Bases:
binf.model.AbstractModel-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 35¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
_check_differentiability(**variables)¶ Checks whether this object can be differentiated w.r.t. specific variables
-
_complete_variables(variables)¶ _complete_variables and _reduce_variables so far only work for classes which both inherit from AbstractBinfNamedCallable and can hold parameters (that is, PDFs and models)
-
_delete_variable(name)¶ Removes a variable from the set of registed variables
Parameters: name (str) – name of the variable to be removed
-
_evaluate(**variables)¶ In this method, the actual function evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_evaluate_gradient(**variables)¶ In this method, the actual gradient evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_get_variables_intersection(test_variables)¶ Returns the intersection of the variables stored in the argument with the set of currently registered variables
-
_reduce_variables(**variables)¶
-
_register(name)¶ Register a new parameter name.
-
_register_variable(name, differentiable=False)¶ Registers a variable so that later on it can be fixed or checked whether it has been passed to the __call__ method
Parameters:
-
_set_original_variables()¶ Stores the original set of named variables this object takes
-
_validate(param, value)¶ Parameter value validation hook. @raise ParameterValueError: on failed validation (value not accepted)
-
data¶
-
differentiable_variables¶ Returns the set of currently registered variables this object implements the gradient w.r.t
Returns: set of variables this object can be differentiated w.r.t. Return type: set
-
fix_variables(**fixed_vars)[source]¶ Sets (‘fixes’) specific variables to values given as keyword arguments by removing these variables from the list of registered variables and registering corresponding parameters to this object.
-
get_params()¶
-
gradient(**variables)¶ This function will be called from outside to evaluate the gradient of the function (or a related one, e.g., log-probability) represented by this object
Parameters: **variables – list of variable name / value pairs Returns: gradient of the function represented by this object Return type: numpy.ndarray
-
name¶ Returns the name of this object
-
parameters¶ Get a list of all distribution parameter names.
-
set_params(*values, **named_params)¶
-
update_var_param_types(**values)¶ Updates the dictionary holding the types of registered variables
-
var_param_types¶ Empty by default, but for a conditional PDF to be built, one has to add AbstractParameter subclasses suiting the variables.
-
Module contents¶
This module contains all “models” occuring in Binf, like the forward models and the error models.
-
class
binf.model.AbstractModel(name, parameters=[])[source]¶ Bases:
binf.AbstractBinfNamedCallableSome copy & pasting from csb.statistics.pdf.AbstractDensity involved.
-
_abc_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache= <_weakrefset.WeakSet object>¶
-
_abc_negative_cache_version= 35¶
-
_abc_registry= <_weakrefset.WeakSet object>¶
-
_check_differentiability(**variables)¶ Checks whether this object can be differentiated w.r.t. specific variables
-
_complete_variables(variables)[source]¶ _complete_variables and _reduce_variables so far only work for classes which both inherit from AbstractBinfNamedCallable and can hold parameters (that is, PDFs and models)
-
_delete_variable(name)¶ Removes a variable from the set of registed variables
Parameters: name (str) – name of the variable to be removed
-
_evaluate(**variables)¶ In this method, the actual function evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_evaluate_gradient(**variables)¶ In this method, the actual gradient evaluation takes place
The variables argument holds values for both fixed and unfixed variables; the implementation in this method thus does not depend on whether the set of originally passed variables equals the set of original variables
Parameters: **variables – list of variable name / value pairs
-
_get_variables_intersection(test_variables)¶ Returns the intersection of the variables stored in the argument with the set of currently registered variables
-
_register_variable(name, differentiable=False)¶ Registers a variable so that later on it can be fixed or checked whether it has been passed to the __call__ method
Parameters:
-
_set_original_variables()¶ Stores the original set of named variables this object takes
-
_validate(param, value)[source]¶ Parameter value validation hook. @raise ParameterValueError: on failed validation (value not accepted)
-
differentiable_variables¶ Returns the set of currently registered variables this object implements the gradient w.r.t
Returns: set of variables this object can be differentiated w.r.t. Return type: set
-
fix_variables(**fixed_vars)¶ Sets (‘fixes’) specific variables to values given as keyword arguments by removing these variables from the list of registered variables and registering corresponding parameters to this object.
-
gradient(**variables)¶ This function will be called from outside to evaluate the gradient of the function (or a related one, e.g., log-probability) represented by this object
Parameters: **variables – list of variable name / value pairs Returns: gradient of the function represented by this object Return type: numpy.ndarray
-
name¶ Returns the name of this object
-
parameters¶ Get a list of all distribution parameter names.
-
update_var_param_types(**values)¶ Updates the dictionary holding the types of registered variables
-
var_param_types¶ Empty by default, but for a conditional PDF to be built, one has to add AbstractParameter subclasses suiting the variables.
-