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.
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 to be less than zero, other than to test with an explicitly broken model. Model Parameters: omega – The precession frequency \(\omega\). Experiment Parameter float: The evolution time \(t\). -
expparams_dtype
¶
-
NoisyCoinModel
- Classical coin flip model corrupted by a noisy process¶
-
class
qinfer.
NoisyCoinModel
[source]¶ Bases:
qinfer.abstract_model.FiniteOutcomeModel
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.
Model Parameters: p – “Heads” probability \(p\).
Experiment Parameters: - alpha (float) – Visibility parameter \(\alpha\).
- beta (float) – Visibility parameter \(\beta\).
-
n_modelparams
¶
-
expparams_dtype
¶
-
is_n_outcomes_constant
¶
NDieModel
¶
-
class
qinfer.
NDieModel
(n=6, threshold=1e-07)[source]¶ Bases:
qinfer.abstract_model.FiniteOutcomeModel
Implements a model of rolling a die with n sides, whose unknown model parameters are the weights of each side; a generalization of CoinModel. An experiment consists of rolling the die once. The faces of the die are zero indexed, labeled 0,1,2,...,n-1.
Parameters: -
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.
-