# Mixin Classes for Model Development¶

## ScoreMixin - Numerical Differentiation for Fisher Scores¶

class qinfer.ScoreMixin[source]

Bases: object

A mixin which includes a method score that numerically estimates the score of the likelihood function. Any class which mixes in this class should be equipped with a property n_modelparams and a method likelihood to satisfy dependency.

h

Returns the step size to be used in numerical differentiation with respect to the model parameters.

The step size is given as a vector with length n_modelparams so that each model parameter can be weighted independently.

score(outcomes, modelparams, expparams, return_L=False)[source]

Returns the numerically computed score of the likelihood function, defined as:

$q(d, \vec{x}; \vec{e}) = \vec{\nabla}_{\vec{x}} \log \Pr(d | \vec{x}; \vec{e}).$

Calls are represented as a four-index tensor score[idx_modelparam, idx_outcome, idx_model, idx_experiment]. The left-most index may be suppressed for single-parameter models.

The numerical gradient is computed using the central difference method, with step size given by the property h.

If return_L is True, both q and the likelihood L are returned as q, L.