Probability¶
- class Probability(outcome, alpha_prior=0.5, validate=True)[source]¶
Compute the mean probability of a single measurement outcome from counts.
This node returns the mean and standard deviation of a single measurement outcome probability
estimated from the observed counts. The mean and variance are computed from the posterior Beta distribution estimated from a Bayesian update of a prior Beta distribution given the observed counts.The mean and variance of the Beta distribution
are:Given a prior Beta distribution
, the posterior distribution for the observation of counts of a given outcome out of total shots is a withNote
The default value for the prior distribution is Jeffery’s Prior
which represents ignorance about the true probability value. Note that for this prior the mean probability estimate from a finite number of counts can never be exactly 0 or 1. The estimated mean and variance are given byThis node will deprecate standard error provided by the previous node.
Initialize a counts to probability data conversion.
- Parameters:
outcome (str) – The bitstring for which to return the probability and variance.
alpha_prior (float | Sequence[float]) – A prior Beta distribution parameter
[alpha0, alpha1]
. If specified as float this will use the same value foralpha0
andalpha1
(Default: 0.5).validate (bool) – If set to False the DataAction will not validate its input.
- Raises:
DataProcessorError – When the dimension of the prior and expected parameter vector do not match.
Methods
- __call__(data)¶
Call the data action of this node on the data.
- Parameters:
data (ndarray) – A numpy array with arbitrary dtype. If the elements are ufloat objects consisting of a nominal value and a standard error, then the error propagation is done automatically.
- Returns:
The processed data.
- Return type:
ndarray