:py:mod:`pygsti.modelmembers.operations.stochasticop` ===================================================== .. py:module:: pygsti.modelmembers.operations.stochasticop .. autoapi-nested-parse:: The StochasticNoiseOp class and supporting functionality. Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: pygsti.modelmembers.operations.stochasticop.StochasticNoiseOp .. py:class:: StochasticNoiseOp(state_space, stochastic_basis='PP', basis='pp', evotype='default', initial_rates=None, seed_or_state=None) Bases: :py:obj:`pygsti.modelmembers.operations.linearop.LinearOperator`, :py:obj:`pygsti.modelmembers.operations.krausop.KrausOperatorInterface` A stochastic noise operation. Implements the stochastic noise map: `rho -> (1-sum(p_i))rho + sum_(i>0) p_i * B_i * rho * B_i^dagger` where `p_i > 0` and `sum(p_i) < 1`, and `B_i` is basis where `B_0` is the identity. In the case of the 'chp' evotype, the `B_i` element is returned with probability `p_i`, such that the outcome distribution matches the aforementioned stochastic noise map when considered over many samples. Parameters ---------- state_space : StateSpace, optional The state space for this operation. basis : Basis or {'pp','gm','qt'}, optional The basis to use, defining the "principle axes" along which there is stochastic noise. We assume that the first element of `basis` is the identity. evotype : Evotype or str, optional The evolution type. The special value `"default"` is equivalent to specifying the value of `pygsti.evotypes.Evotype.default_evotype`. initial_rates : list or array if not None, a list of `basis.size-1` initial error rates along each of the directions corresponding to each basis element. If None, then all initial rates are zero. seed_or_state : float or RandomState, optional Random seed for RandomState (or directly provided RandomState) for sampling stochastic superoperators with the 'chp' evotype. Initialize a new LinearOperator .. py:property:: num_params Get the number of independent parameters which specify this operation. Returns ------- int the number of independent parameters. .. py:property:: total_term_magnitude Get the total (sum) of the magnitudes of all this operator's terms. The magnitude of a term is the absolute value of its coefficient, so this function returns the number you'd get from summing up the absolute-coefficients of all the Taylor terms (at all orders!) you get from expanding this operator in a Taylor series. Returns ------- float .. py:property:: total_term_magnitude_deriv The derivative of the sum of *all* this operator's terms. Computes the derivative of the total (sum) of the magnitudes of all this operator's terms with respect to the operators (local) parameters. Returns ------- numpy array An array of length self.num_params .. py:property:: kraus_operators A list of this operation's Kraus operators as numpy arrays. .. py:attribute:: basis .. py:attribute:: params .. py:attribute:: stochastic_basis .. py:method:: to_dense(on_space: pygsti.SpaceT = 'minimal') Return this operation as a dense matrix. Parameters ---------- on_space : {'minimal', 'Hilbert', 'HilbertSchmidt'} The space that the returned dense operation acts upon. For unitary matrices and bra/ket vectors, use `'Hilbert'`. For superoperator matrices and super-bra/super-ket vectors use `'HilbertSchmidt'`. `'minimal'` means that `'Hilbert'` is used if possible given this operator's evolution type, and otherwise `'HilbertSchmidt'` is used. Returns ------- numpy.ndarray .. py:method:: to_vector() Extract a vector of the underlying operation parameters from this operation. Returns ------- numpy array a 1D numpy array with length == num_params(). .. py:method:: from_vector(v, close=False, dirty_value=True) Initialize the operation using a vector of parameters. Parameters ---------- v : numpy array The 1D vector of operation parameters. Length must == num_params() close : bool, optional Whether `v` is close to this operation's current set of parameters. Under some circumstances, when this is true this call can be completed more quickly. dirty_value : bool, optional The value to set this object's "dirty flag" to before exiting this call. This is passed as an argument so it can be updated *recursively*. Leave this set to `True` unless you know what you're doing. Returns ------- None .. py:method:: taylor_order_terms(order, max_polynomial_vars=100, return_coeff_polys=False) Get the `order`-th order Taylor-expansion terms of this operation. This function either constructs or returns a cached list of the terms at the given order. Each term is "rank-1", meaning that its action on a density matrix `rho` can be written: `rho -> A rho B` The coefficients of these terms are typically polynomials of the operation's parameters, where the polynomial's variable indices index the *global* parameters of the operation's parent (usually a :class:`Model`), not the operation's local parameter array (i.e. that returned from `to_vector`). Parameters ---------- order : int Which order terms (in a Taylor expansion of this :class:`LindbladOp`) to retrieve. max_polynomial_vars : int, optional maximum number of variables the created polynomials can have. return_coeff_polys : bool Whether a parallel list of locally-indexed (using variable indices corresponding to *this* object's parameters rather than its parent's) polynomial coefficients should be returned as well. Returns ------- terms : list A list of :class:`RankOneTerm` objects. coefficients : list Only present when `return_coeff_polys == True`. A list of *compact* polynomial objects, meaning that each element is a `(vtape,ctape)` 2-tuple formed by concatenating together the output of :meth:`Polynomial.compact`. .. py:method:: set_kraus_operators(kraus_operators) Set the parameters of this operation by specifying its Kraus operators. Parameters ---------- kraus_operators : list A list of numpy arrays, each of which specifies a Kraus operator. Returns ------- None .. py:method:: to_memoized_dict(mmg_memo) Create a serializable dict with references to other objects in the memo. Parameters ---------- mmg_memo: dict Memo dict from a ModelMemberGraph, i.e. keys are object ids and values are ModelMemberGraphNodes (which contain the serialize_id). This is NOT the same as other memos in ModelMember (e.g. copy, allocate_gpindices, etc.). Returns ------- mm_dict: dict A dict representation of this ModelMember ready for serialization This must have at least the following fields: module, class, submembers, params, state_space, evotype Additional fields may be added by derived classes.