pub struct DetectorErrorModel {
pub num_detectors: usize,
pub num_observables: usize,
pub errors: Vec<DEMError>,
pub coordinate_shifts: Vec<Vec<f64>>,
pub detector_coords: HashMap<usize, Vec<f64>>,
}Expand description
Detector Error Model representation
Fields§
§num_detectors: usizeNumber of detectors in the circuit
num_observables: usizeNumber of logical observables
errors: Vec<DEMError>List of error mechanisms
coordinate_shifts: Vec<Vec<f64>>Coordinate system shifts (for visualization)
detector_coords: HashMap<usize, Vec<f64>>Detector coordinates
Implementations§
Source§impl DetectorErrorModel
impl DetectorErrorModel
Sourcepub fn from_circuit(circuit: &StimCircuit) -> Result<Self>
pub fn from_circuit(circuit: &StimCircuit) -> Result<Self>
Generate a DEM from a Stim circuit
This performs error analysis by:
- Identifying all error mechanisms in the circuit
- Propagating each error through to detectors/observables
- Recording which detectors/observables are affected
Sourcepub fn to_dem_string(&self) -> String
pub fn to_dem_string(&self) -> String
Convert DEM to Stim DEM format string
Sourcepub fn from_dem_string(s: &str) -> Result<Self>
pub fn from_dem_string(s: &str) -> Result<Self>
Parse a DEM from string
Sourcepub fn sample(&self) -> (Vec<bool>, Vec<bool>)
pub fn sample(&self) -> (Vec<bool>, Vec<bool>)
Sample errors according to the DEM
Returns (detector_outcomes, observable_flips) for a single sample
Sourcepub fn sample_batch(&self, num_shots: usize) -> Vec<(Vec<bool>, Vec<bool>)>
pub fn sample_batch(&self, num_shots: usize) -> Vec<(Vec<bool>, Vec<bool>)>
Sample multiple shots
Sourcepub fn total_error_probability(&self) -> f64
pub fn total_error_probability(&self) -> f64
Get the total error probability
Sourcepub fn num_error_mechanisms(&self) -> usize
pub fn num_error_mechanisms(&self) -> usize
Get number of error mechanisms
Trait Implementations§
Source§impl Clone for DetectorErrorModel
impl Clone for DetectorErrorModel
Source§fn clone(&self) -> DetectorErrorModel
fn clone(&self) -> DetectorErrorModel
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DetectorErrorModel
impl RefUnwindSafe for DetectorErrorModel
impl Send for DetectorErrorModel
impl Sync for DetectorErrorModel
impl Unpin for DetectorErrorModel
impl UnwindSafe for DetectorErrorModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.