:py:mod:`pygsti.tools.errgenproptools` ====================================== .. py:module:: pygsti.tools.errgenproptools .. autoapi-nested-parse:: Tools for the propagation of error generators through circuits. Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: pygsti.tools.errgenproptools.errgen_coeff_label_to_stim_pauli_strs pygsti.tools.errgenproptools.bch_approximation pygsti.tools.errgenproptools.magnus_expansion pygsti.tools.errgenproptools.error_generator_commutator pygsti.tools.errgenproptools.error_generator_composition pygsti.tools.errgenproptools.com pygsti.tools.errgenproptools.acom pygsti.tools.errgenproptools.pauli_product pygsti.tools.errgenproptools.stim_pauli_string_less_than pygsti.tools.errgenproptools.errorgen_pauli_action pygsti.tools.errgenproptools.errorgen_layer_to_matrix pygsti.tools.errgenproptools.iterative_error_generator_composition pygsti.tools.errgenproptools.error_generator_commutator_numerical pygsti.tools.errgenproptools.error_generator_composition_numerical pygsti.tools.errgenproptools.bch_numerical pygsti.tools.errgenproptools.pairwise_bch_numerical pygsti.tools.errgenproptools.magnus_numerical pygsti.tools.errgenproptools.errorgen_pauli_action_numerical pygsti.tools.errgenproptools.iterative_error_generator_composition_numerical pygsti.tools.errgenproptools.random_support pygsti.tools.errgenproptools.tableau_fidelity pygsti.tools.errgenproptools.bitstring_to_tableau pygsti.tools.errgenproptools.amplitude_of_state pygsti.tools.errgenproptools.pauli_phase_update pygsti.tools.errgenproptools.phi pygsti.tools.errgenproptools.phi_numerical pygsti.tools.errgenproptools.alpha pygsti.tools.errgenproptools.alpha_numerical pygsti.tools.errgenproptools.alpha_pauli pygsti.tools.errgenproptools.alpha_pauli_numerical pygsti.tools.errgenproptools.stabilizer_probability_correction pygsti.tools.errgenproptools.stabilizer_pauli_expectation_correction pygsti.tools.errgenproptools.stabilizer_pauli_expectation_correction_numerical pygsti.tools.errgenproptools.stabilizer_probability pygsti.tools.errgenproptools.stabilizer_pauli_expectation pygsti.tools.errgenproptools.approximate_stabilizer_probability pygsti.tools.errgenproptools.approximate_stabilizer_pauli_expectation pygsti.tools.errgenproptools.approximate_stabilizer_pauli_expectation_numerical pygsti.tools.errgenproptools.approximate_stabilizer_probabilities pygsti.tools.errgenproptools.error_generator_taylor_expansion pygsti.tools.errgenproptools.error_generator_taylor_expansion_numerical Attributes ~~~~~~~~~~ .. autoapisummary:: pygsti.tools.errgenproptools.msg .. py:data:: msg :value: "'Stim is required for use of the error generator propagation tools module, and it does not..." .. py:function:: errgen_coeff_label_to_stim_pauli_strs(err_gen_coeff_label, num_qubits) Converts an input `GlobalElementaryErrorgenLabel` to a tuple of stim.PauliString objects, padded with an appropriate number of identities. Parameters ---------- err_gen_coeff_label : `GlobalElementaryErrorgenLabel` or `LocalElementaryErrorgenLabel` The error generator coefficient label to construct the tuple of pauli strings for. num_qubits : int Number of total qubits to use for the Pauli strings. Used to determine the number of identities added when padding. Returns ------- tuple of stim.PauliString A tuple of either length 1 (for H and S) or length 2 (for C and A) whose entries are stim.PauliString representations of the indices for the input error generator label, padded with an appropriate number of identities given the support of the error generator label. .. py:function:: bch_approximation(errgen_layer_1, errgen_layer_2, bch_order=1, truncation_threshold=1e-14) Apply the BCH approximation at the given order to combine the input dictionaries of error generator rates. Parameters ---------- errgen_layer_1 : dict Dictionary of the error generator coefficients and rates for a circuit layer. The error generator coefficients are represented using LocalStimErrorgenLabel. errgen_layer_2 : list of dicts See errgen_layer_1. bch_order : int, optional (default 1) Order of the BCH approximation to use. Currently support for up to fifth order. truncation_threshold : float, optional (default 1e-14) Threshold for which any error generators with magnitudes below this value are truncated. Returns ------- combined_errgen_layer : dict A dictionary with the same general structure as `errgen_layer_1` and `errgen_layer_2`, but with the rates combined according to the selected order of the BCH approximation. .. py:function:: magnus_expansion(errorgen_layers: list[dict[pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, float]], magnus_order: Literal[1, 2, 3] = 1, truncation_threshold: float = 1e-14) -> dict[pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, float] Function for computing the nth-order magnus expansion for a set of error generator layers. Please see https://arxiv.org/abs/0810.5488 or https://en.wikipedia.org/wiki/Magnus_expansion for more information on this approximation. Parameters ---------- errorgen_layers : list of dicts List of dictionaries of the error generator coefficients and rates for a circuit layer. The error generator coefficients are represented using LocalStimErrorgenLabel. errorgen_transform_maps : dict Map giving the relationship between input error generators and their final value following propagation through the circuit. Needed to track any sign updates for terms with zero mean but nontrivial covariance. cov_func : A function which maps tuples of elementary error generator labels at multiple times to a scalar quantity corresponding to the value of the covariance for that pair. magnus_order : int, optional (default 1) Order of the magnus expansion to apply. Currently supports up to third order. truncation_threshold : float, optional (default 1e-14) Threshold for which any error generators with magnitudes below this value are truncated. Returns ------- magnus_expansion_dict : dict A dictionary with the same general structure as those in `errorgen_layers`, but with the rates combined according to the selected order of the magnus expansion. .. py:function:: error_generator_commutator(errorgen_1, errorgen_2, flip_weight=False, weight=1.0, identity=None) Returns the commutator of two error generators. I.e. [errorgen_1, errorgen_2]. Parameters ---------- errorgen1 : `LocalStimErrorgenLabel` First error generator. errorgen2 : `LocalStimErrorgenLabel` Second error generator flip_weight : bool, optional (default False) If True flip the sign of the input value of weight kwarg. weight : float, optional (default 1.0) An optional weighting value to apply to the value of the commutator. identity : stim.PauliString, optional (default None) An optional stim.PauliString to use for comparisons to the identity. Passing in this kwarg isn't necessary, but can allow for reduced stim.PauliString creation when calling this function many times for improved efficiency. Returns ------- list of `LocalStimErrorgenLabel`s corresponding to the commutator of the two input error generators, weighted by the specified value of `weight`. .. py:function:: error_generator_composition(errorgen_1, errorgen_2, weight=1.0, identity=None) Returns the composition of two error generators. I.e. errorgen_1[errorgen_2[\cdot]]. Parameters ---------- errorgen1 : `LocalStimErrorgenLabel` First error generator. errorgen2 : `LocalStimErrorgenLabel` Second error generator weight : float, optional (default 1.0) An optional weighting value to apply to the value of the composition. identity : stim.PauliString, optional (default None) An optional stim.PauliString to use for comparisons to the identity. Passing in this kwarg isn't necessary, but can allow for reduced stim.PauliString creation when calling this function many times for improved efficiency. Returns ------- list of tuples. The first element of each tuple is a `LocalStimErrorgenLabel`s corresponding to a component of the composition of the two input error generators. The second element is the weight of that term, additionally weighted by the specified value of `weight`. .. py:function:: com(P1, P2) .. py:function:: acom(P1, P2) .. py:function:: pauli_product(P1, P2) .. py:function:: stim_pauli_string_less_than(pauli1, pauli2) Returns true if pauli1 is less than pauli lexicographically. Parameters ---------- pauli1, pauli2 : stim.PauliString Paulis to compare. .. py:function:: errorgen_pauli_action(errorgen: pygsti.errorgenpropagation.localstimerrorgen.LocalStimErrorgenLabel, pauli: stim.PauliString) -> tuple[float, stim.PauliString] Apply the specified error generator to a given Pauli operator. Parameters ---------- errorgen : `LocalStimErrorgenLabel` A label specifying the error generator which should be applied to the specified Pauli operator. pauli : stim.PauliString The pauli operator to apply the error generator to Returns: -------- A tuple whose first value is the (generally complex) weight of the resulting pauli operator, and whose second value is the unsigned Pauli operator itself. If the specified error generator annihilates the given pauli then this instead returns None. .. py:function:: errorgen_layer_to_matrix(errorgen_layer, num_qubits, errorgen_matrix_dict=None, sslbls=None) Converts an iterable over error generator coefficients and rates into the corresponding dense numpy array representation. Parameters ---------- errorgen_layer : list, tuple or dict An iterable over error generator coefficient and rates. If a list or a tuple the elements should correspond to two-element tuples, the first value being an `ElementaryErrorgenLabel` and the second value the rate. If a dictionary the keys should be `ElementaryErrorgenLabel` and the values the rates. num_qubits : int Number of qubits for the error generator matrix being constructed. errorgen_matrix_dict : dict, optional (default None) An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit. sslbls : list or tuple, optional (default None) A tuple or list of state space labels corresponding to the qubits upon which the error generators can supported. Only required when passing in a value of `errorgen_matrix_dict` with `GlobalElementaryErrogenLabel` keys in conjunction with an `errorgen_layer` with labels which are `LocalElementaryErrorgenLabel` (or vice-versa). Returns ------- errorgen_mat : ndarray ndarray for the dense representation of the specified error generator in the standard basis. .. py:function:: iterative_error_generator_composition(errorgen_labels, rates) Iteratively compute error generator compositions. Each error generator composition in general returns a list of multiple new error generators, so this function manages the distribution and recursive application of the compositions for two-or-more error generator labels. Parameters ---------- errorgen_labels : tuple of `LocalStimErrorgenLabel` A tuple of the elementary error generator labels to be composed. rates : tuple of float A tuple of corresponding error generator rates of the same length as the tuple of error generator labels. Returns ------- List of tuples, the first element of each tuple is a `LocalStimErrorgenLabel`. The second element of each tuple is the final rate for that term. .. py:function:: error_generator_commutator_numerical(errorgen1, errorgen2, errorgen_matrix_dict=None, num_qubits=None) Numerically compute the commutator of the two specified elementary error generators. Parameters ---------- errorgen1 : `LocalElementaryErrorgenLabel` or `LocalStimErrorgenLabel` First error generator. errorgen2 : `ElementaryErrorgenLabel` or `LocalStimErrorgenLabel` Second error generator. errorgen_matrix_dict : dict, optional (default None) An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit. num_qubits : int, optional (default None) Number of qubits for the error generator commutator being computed. Only required if `errorgen_matrix_dict` is None. Returns ------- ndarray Numpy array corresponding to the dense representation of the commutator of the input error generators in the standard basis. .. py:function:: error_generator_composition_numerical(errorgen1, errorgen2, errorgen_matrix_dict=None, num_qubits=None) Numerically compute the composition of the two specified elementary error generators. Parameters ---------- errorgen1 : `LocalElementaryErrorgenLabel` or `LocalStimErrorgenLabel` First error generator. errorgen2 : `ElementaryErrorgenLabel` or `LocalStimErrorgenLabel` Second error generator. errorgen_matrix_dict : dict, optional (default None) An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit. num_qubits : int, optional (default None) Number of qubits for the error generator commutator being computed. Only required if `errorgen_matrix_dict` is None. Returns ------- ndarray Numpy array corresponding to the dense representation of the composition of the input error generators in the standard basis. .. py:function:: bch_numerical(propagated_errorgen_layers, error_propagator, bch_order=1) Iteratively compute effective error generator layer produced by applying the BCH approximation to the list of input error generator matrices. Note this is primarily intended as part of testing and validation infrastructure. Parameters ---------- propagated_errorgen_layers : list of numpy.ndarrays List of the error generator layers to combine using the BCH approximation (in circuit ordering) error_propagator : `ErrorGeneratorPropagator` An `ErrorGeneratorPropagator` instance to use as part of the BCH calculation. bch_order : int, optional (default 1) Order of the BCH approximation to apply (up to 5 is supported currently). Returns ------- numpy.ndarray A dense numpy array corresponding to the result of the iterative application of the BCH approximation. .. py:function:: pairwise_bch_numerical(mat1, mat2, order=1) Helper function for doing the numerical BCH in a pairwise fashion. Note this function is primarily intended for numerical validations as part of testing infrastructure. .. py:function:: magnus_numerical(propagated_errorgen_layers: list[dict[pygsti.baseobjs.errorgenlabel.ElementaryErrorgenLabel, float]], error_propagator: pygsti.errorgenpropagation.errorpropagator.ErrorGeneratorPropagator, magnus_order: Literal[1, 2, 3] = 1) -> numpy.ndarray Compute effective error generator layer produced by applying the magnus expansions to the list of input error generator matrices. Note this is primarily intended as part of testing and validation infrastructure. Parameters ---------- propagated_errorgen_layers : list of dictionaries List of the error generator layers (in circuit ordering) in the form of dictionaries whose keys are elementary error generator labels and whose values are their corresponding rates. These dictionaries are in the format produced by the `ErrorGeneratorPropagator` class's `propagate_errorgens` method. error_propagator : `ErrorGeneratorPropagator` An `ErrorGeneratorPropagator` instance to use as part of the Magnus calculation. magnus_order : int, optional (default 1) Order of the Magnus expansion to apply (up to 3 is supported currently). Returns ------- numpy.ndarray A dense numpy array corresponding to the result of Magnus expansion. .. py:function:: errorgen_pauli_action_numerical(errorgen: pygsti.baseobjs.errorgenlabel.ElementaryErrorgenLabel, pauli: stim.PauliString) -> numpy.ndarray Apply the specified error generator to a given Pauli operator. This implementation performs the application of the error generator numerically and is primarily intended for use in testing. Parameters ---------- errorgen : `ElementaryErrorgenLabel` or numpy.ndarray A label specifying the error generator which should be applied to the specified Pauli operator or else a dense numpy array for the error generator (in the standard basis). pauli : stim.PauliString The pauli operator to apply the error generator to. Returns: -------- numpy.ndarray Dense representation of the weighted pauli operator resulting from the application of the specified error generator to the input pauli. .. py:function:: iterative_error_generator_composition_numerical(errorgen_labels, rates, errorgen_matrix_dict=None, num_qubits=None) Iteratively compute error generator compositions. The function computes a dense representation of this composition numerically and is primarily intended as part of testing infrastructure. Parameters ---------- errorgen_labels : tuple of `LocalStimErrorgenLabel` A tuple of the elementary error generator labels to be composed. rates : tuple of float A tuple of corresponding error generator rates of the same length as the tuple of error generator labels. errorgen_matrix_dict : dict, optional (default None) An optional dictionary mapping `ElementaryErrorgenLabel`s to numpy arrays for their dense representation. If not specified this will be constructed from scratch each call, so specifying this can provide a performance benefit. num_qubits : int, optional (default None) Number of qubits for the error generator commutator being computed. Only required if `errorgen_matrix_dict` is None. Returns ------- numpy.ndarray Dense numpy array representation of the super operator corresponding to the iterated composition written in the standard basis. .. py:function:: random_support(tableau, return_support=False) Compute the number of bits over which the stabilizer state corresponding to this stim tableau would have measurement outcomes which are random. Parameters ---------- tableau : stim.Tableau stim.Tableau corresponding to the stabilizer state we want the random support for. return_support : bool, optional (default False) If True also returns a list of qubit indices over which the distribution of outcome bit strings is random. .. py:function:: tableau_fidelity(tableau1, tableau2) Calculate the fidelity between the stabilizer states corresponding to the given stim tableaus. This returns a result in units of probability (so this may be squared fidelity depending on your convention). Parameters ---------- tableau1 : stim.Tableau Stim tableau for first stabilizer state. tableau2 : stim.Tableau Stim tableau for second stabilizer state. .. py:function:: bitstring_to_tableau(bitstring) Map a computational basis bit string into a corresponding Tableau which maps the all zero state into that state. Parameters ---------- bitstring : str String of 0's and 1's corresponding to the computational basis state to prepare the Tableau for. Returns ------- stim.Tableau Tableau which maps the all zero string to this computational basis state .. py:function:: amplitude_of_state(tableau, desired_state) Get the amplitude of a particular computational basis state for given stabilizer state. Parameters ---------- tableau : stim.Tableau Stim tableau corresponding to the stabilizer state we wish to extract the amplitude from. desired_state : str String of 0's and 1's corresponding to the computational basis state to extract the amplitude for. .. py:function:: pauli_phase_update(pauli, bitstring, dual=False) Takes as input a pauli and a bit string and computes the output bitstring and the overall phase that bit string accumulates. Parameters ---------- pauli : str or stim.PauliString Pauli to apply bitstring : str String of 0's and 1's representing the bit string to apply the pauli to. dual : bool, optional (default False) If True then then the pauli is acting to the left on a row vector. Returns ------- Tuple whose first element is the phase accumulated, and whose second element is a string corresponding to the updated bit string. .. py:function:: phi(tableau, desired_bitstring, P, Q) This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators. Parameters ---------- tableau : stim.Tableau A stim Tableau corresponding to the input stabilizer state. desired_bitstring : str A string of zeros and ones corresponding to the bit string being measured. P : str or stim.PauliString The first pauli string index. Q : str or stim.PauliString The second pauli string index. Returns ------- A complex number corresponding to the value of the phi function. .. py:function:: phi_numerical(tableau, desired_bitstring, P, Q) This function computes a quantity whose value is used in expression for the sensitivity of probabilities to error generators. (This version does this calculation numerically and is primarily intended for testing infrastructure.) Parameters ---------- tableau : stim.Tableau A stim Tableau corresponding to the input stabilizer state. desired_bitstring : str A string of zeros and ones corresponding to the bit string being measured. P : str or stim.PauliString The first pauli string index. Q : str or stim.PauliString The second pauli string index. Returns ------- A complex number corresponding to the value of the phi function. .. py:function:: alpha(errorgen, tableau, desired_bitstring) First-order error generator sensitivity function for probability. Parameters ---------- errorgen : `ElementaryErrorgenLabel` Error generator label for which to calculate sensitivity. tableau : stim.Tableau Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for. desired_bitstring : str Bit string to calculate the sensitivity for. .. py:function:: alpha_numerical(errorgen, tableau, desired_bitstring) First-order error generator sensitivity function for probability. This implementation calculates this quantity numerically, and as such is primarily intended for used as parting of testing infrastructure. Parameters ---------- errorgen : `ElementaryErrorgenLabel` Error generator label for which to calculate sensitivity. tableau : stim.Tableau Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for. desired_bitstring : str Bit string to calculate the sensitivity for. .. py:function:: alpha_pauli(errorgen, tableau, pauli) First-order error generator sensitivity function for pauli expectations. Parameters ---------- errorgen : `ElementaryErrorgenLabel` Error generator label for which to calculate sensitivity. tableau : stim.Tableau Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for. pauli : stim.PauliString Pauli to calculate the sensitivity for. .. py:function:: alpha_pauli_numerical(errorgen, tableau, pauli) First-order error generator sensitivity function for pauli expectatons. This implementation calculates this quantity numerically, and as such is primarily intended for used as parting of testing infrastructure. Parameters ---------- errorgen : `ElementaryErrorgenLabel` Error generator label for which to calculate sensitivity. tableau : stim.Tableau Stim Tableau corresponding to the stabilizer state to calculate the sensitivity for. pauli : stim.PauliString Pauli to calculate the sensitivity for. .. py:function:: stabilizer_probability_correction(errorgen_dict, tableau, desired_bitstring, order=1, truncation_threshold=1e-14) Compute the kth-order correction to the probability of the specified bit string. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `LocalStimErrorgenLabel` and whose values are corresponding rates. tableau : stim.Tableau Stim tableau corresponding to a particular stabilizer state being measured. desired_bitstring : str String of 0's and 1's corresponding to the output bitstring being measured. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding rates are below this value. Returns ------- correction : float float corresponding to the correction to the output probability for the desired bitstring induced by the error generator (to specified order). .. py:function:: stabilizer_pauli_expectation_correction(errorgen_dict, tableau, pauli, order=1, truncation_threshold=1e-14) Compute the kth-order correction to the expectation value of the specified pauli. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `LocalStimErrorgenLabel` and whose values are corresponding rates. tableau : stim.Tableau Stim tableau corresponding to a particular stabilizer state being measured. pauli : stim.PauliString Pauli operator to compute expectation value correction for. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding rates are below this value. Returns ------- correction : float float corresponding to the correction to the expectation value for the selected pauli operator induced by the error generator (to specified order). .. py:function:: stabilizer_pauli_expectation_correction_numerical(errorgen_dict, errorgen_propagator, circuit, pauli, order=1) Compute the kth-order correction to the expectation value of the specified pauli. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `LocalStimErrorgenLabel` and whose values are corresponding rates. errorgen_propagator : `ErrorGeneratorPropagator` Error generator propagator used for constructing dense representation of the error generator dictionary. circuit : `Circuit` Circuit the expectation value is being measured against. pauli : stim.PauliString Pauli operator to compute expectation value correction for. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. Returns ------- correction : float float corresponding to the correction to the expectation value for the selected pauli operator induced by the error generator (to specified order). .. py:function:: stabilizer_probability(tableau, desired_bitstring) Calculate the output probability for the specifed output bitstring. TODO: Should be able to do this more efficiently for many bitstrings by looking at the structure of the random support. Parameters ---------- tableau : stim.Tableau Stim tableau for the stabilizer state being measured. desired_bitstring : str String of 0's and 1's corresponding to the output bitstring being measured. Returns ------- p : float probability of desired bitstring. .. py:function:: stabilizer_pauli_expectation(tableau, pauli) Calculate the output probability for the specifed output bitstring. Parameters ---------- tableau : stim.Tableau Stim tableau for the stabilizer state being measured. pauli : stim.PauliString Pauli operator to compute expectation value for. Returns ------- expected_value : float Expectation value of specified pauli .. py:function:: approximate_stabilizer_probability(errorgen_dict, circuit, desired_bitstring, order=1, truncation_threshold=1e-14) Calculate the approximate probability of a desired bit string using an nth-order taylor series approximation. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `ElementaryErrorgenLabel` and whose values are corresponding rates. circuit : `Circuit` or `stim.Tableau` A pygsti `Circuit` or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau. desired_bitstring : str String of 0's and 1's corresponding to the output bitstring being measured. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections) Returns ------- p : float Approximate output probability for desired bitstring. .. py:function:: approximate_stabilizer_pauli_expectation(errorgen_dict, circuit, pauli, order=1, truncation_threshold=1e-14) Calculate the approximate probability of a desired bit string using a first-order approximation. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `ElementaryErrorgenLabel` and whose values are corresponding rates. circuit : `Circuit` or `stim.Tableau` A pygsti `Circuit` or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau. pauli : str or stim.PauliString Pauli operator to compute expectation value for. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections) Returns ------- expectation_value : float Approximate expectation value for desired pauli. .. py:function:: approximate_stabilizer_pauli_expectation_numerical(errorgen_dict, errorgen_propagator, circuit, pauli, order=1) Calculate the approximate probability of a desired bit string using a first-order approximation. This function performs the corrections numerically and so it primarily intended for testing infrastructure. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `ElementaryErrorgenLabel` and whose values are corresponding rates. errorgen_propagator : `ErrorGeneratorPropagator` Error generator propagator used for constructing dense representation of the error generator dictionary. circuit : `Circuit` A pygsti `Circuit` or a stim.Tableau to compute the output pauli expectation value for. pauli : stim.PauliString Pauli operator to compute expectation value for. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections) Returns ------- expectation_value : float Approximate expectation value for desired pauli. .. py:function:: approximate_stabilizer_probabilities(errorgen_dict, circuit, order=1, truncation_threshold=1e-14) Calculate the approximate probability distribution over all bitstrings using a first-order approximation. Note the size of this distribtion scales exponentially in the qubit count, so this is very inefficient for any more than a few qubits. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `ElementaryErrorgenLabel` and whose values are corresponding rates. circuit : `Circuit` or `stim.Tableau` A pygsti `Circuit` or a stim.Tableau to compute the output probability for. In either case this should be a Clifford circuit and convertable to a stim.Tableau. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding error generator rates are below this value. (Used internally in computation of probability corrections) Returns ------- p : float Approximate output probability for desired bitstring. .. py:function:: error_generator_taylor_expansion(errorgen_dict, order=1, truncation_threshold=1e-14) Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input error generator dictionary. (Excluding the zeroth-order identity). Parameters ---------- errorgen_dict : dict Dictionary whose keys are `LocalStimErrorgenLabel` and whose values are corresponding rates. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. truncation_threshold : float, optional (default 1e-14) Optional threshold used to truncate corrections whose corresponding rates are below this value. Returns ------- list of dictionaries List of dictionaries whose keys are error generator labels and whose values are rates (including whatever scaling comes from order of taylor expansion). Each list corresponds to an order of the taylor expansion. .. py:function:: error_generator_taylor_expansion_numerical(errorgen_dict, errorgen_propagator, order=1, mx_basis='pp') Compute the nth-order taylor expansion for the exponentiation of the error generator described by the input error generator dictionary. (Excluding the zeroth-order identity). This function computes a dense representation of this taylor expansion as a numpy array and is primarily intended for testing infrastructure. Parameters ---------- errorgen_dict : dict Dictionary whose keys are `LocalStimErrorgenLabel` and whose values are corresponding rates. errorgen_propagator : `ErrorGeneratorPropagator` Error generator propagator used for constructing dense representation of the error generator dictionary. order : int, optional (default 1) Order of the correction (i.e. order of the taylor series expansion for the exponentiated error generator) to compute. mx_basis : `Basis` or str, optional (default 'pp') Basis in which to return the matrix. Returns ------- numpy.ndarray A dense numpy array corresponding to the nth order taylor expansion of the specified error generator.