Testing Models¶
Introduction¶
QInfer provides several premade models for quickly learning how to use the library, for making demonstrations, or to test new algorithms and approaches built on top of QInfer.
SimplePrecessionModel
 Model of a single qubit undergoing Larmor precession¶

class
qinfer.test_models.
SimplePrecessionModel
(min_freq=0)[source]¶ Bases:
qinfer.test_models.SimpleInversionModel
Describes the free evolution of a single qubit prepared in the \(\left+\right\rangle\) state under a Hamiltonian \(H = \omega \sigma_z / 2\), as explored in [GFWC12].
Parameters: min_freq (float) – Minimum value for \(\omega\) to accept as valid. This is used for testing techniques that mitigate the effects of degenerate models; there is no “good” reason to ever set this other than zero, other than to test with an explicitly broken model. 
expparams_dtype
¶

NoisyCoinModel
 Classical coin flip model corrupted by a noisy process¶

class
qinfer.test_models.
NoisyCoinModel
[source]¶ Bases:
qinfer.abstract_model.Model
Implements the “noisy coin” model of [FB12], where the model parameter \(p\) is the probability of the noisy coin. This model has two experiment parameters, \(\alpha\) and \(\beta\), which are the probabilities of observing a “0” outcome conditoned on the “true” outcome being 0 and 1, respectively. That is, for an ideal coin, \(\alpha = 1\) and \(\beta = 0\).
Note that \(\alpha\) and \(\beta\) are implemented as experiment parameters not because we expect to design over those values, but because a specification of each is necessary to honestly describe an experiment that was performed.

n_modelparams
¶

expparams_dtype
¶

is_n_outcomes_constant
¶

NDieModel
¶

class
qinfer.test_models.
NDieModel
(n=6)[source]¶ Bases:
qinfer.abstract_model.Model

n_modelparams
¶

expparams_dtype
¶

is_n_outcomes_constant
¶ Returns
True
if and only if the number of outcomes for each experiment is independent of the experiment being performed.This property is assumed by inference engines to be constant for the lifetime of a Model instance.

n_outcomes
(expparams)[source]¶ Returns an array of dtype
uint
describing the number of outcomes for each experiment specified byexpparams
.Parameters: expparams (numpy.ndarray) – Array of experimental parameters. This array must be of dtype agreeing with the expparams_dtype
property.
