Struct roqoqo::noise_models::ImperfectReadoutModel

source ·
pub struct ImperfectReadoutModel {
    prob_detect_0_as_1: HashMap<usize, f64>,
    prob_detect_1_as_0: HashMap<usize, f64>,
}
Expand description

Noise model representing readout errors.

Readout errors are modeled by two probabilities in this simple model. One probability to detect a 1 instead of a 0 when the quantum measurement gives 0 and one probability to detect a 0 instead of a 1 when the quantum measurement gives 1.

§Example

use roqoqo::noise_models::ImperfectReadoutModel;

let model = ImperfectReadoutModel::new_with_uniform_error(3, 0.5, 0.5).unwrap();
let model = model.set_error_probabilites(2, 0.3, 0.7).unwrap();
let uniform_prob = model.prob_detect_0_as_1(&0);
assert_eq!(uniform_prob, 0.5);
let lower_prob = model.prob_detect_0_as_1(&2);
assert_eq!(lower_prob, 0.3);
let higher_prob = model.prob_detect_1_as_0(&2);
assert_eq!(higher_prob, 0.7);

Fields§

§prob_detect_0_as_1: HashMap<usize, f64>

Decoherence rates for all qubits

§prob_detect_1_as_0: HashMap<usize, f64>

Implementations§

source§

impl ImperfectReadoutModel

source

pub fn new() -> Self

Create a new empty ContinuousDecoherenceModel.

§Returns
  • ImperfectReadoutModel - The new model
source

pub fn new_with_uniform_error( number_qubits: usize, prob_detect_0_as_1: f64, prob_detect_1_as_0: f64, ) -> Result<Self, RoqoqoBackendError>

Convenience function to create uniform error probabilities

§Arguments
  • number_qubits - The number of qubits the uniform error probabilites should be initialized for.
  • prob_detect_0_as_1 - The error probability to detect a 1 instead of a 0 when measuring 0
  • prob_detect_1_as_0 - The error probability to detect a 0 instead of a 1 when measuring 1
§Returns
  • Ok(ImperfectReadoutModel) - The new error model
  • Err(RoqoqoError) - Probabilities are not valid (< 0 or > 1)
source

pub fn set_error_probabilites( self, qubit: usize, prob_detect_0_as_1: f64, prob_detect_1_as_0: f64, ) -> Result<Self, RoqoqoBackendError>

Set and overwrite the measurement error probabilities

§Arguments
  • qubits - The qubits for which error rates are set.
  • prob_detect_0_as_1 - The error probability to detect a 1 instead of a 0 when measuring 0
  • prob_detect_1_as_0 - The error probability to detect a 0 instead of a 1 when measuring 1
§Returns
  • Ok(ImperfectReadoutModel) - The new error model
  • Err(RoqoqoError) - Probabilities are not valid (< 0 or > 1)
source

pub fn prob_detect_0_as_1(&self, qubit: &usize) -> f64

Return probability to detect 0 as 1 for a qubit

§Arguments

qubit - The qubit for which the probability is returned.

§Returns

f64 - The probability to detect 0 as 1 for the qubit

source

pub fn prob_detect_1_as_0(&self, qubit: &usize) -> f64

Return probability to detect 1 as 0 for a qubit

§Arguments

qubit - The qubit for which the probability is returned.

§Returns

f64 - The probability to detect 1 as 0 for the qubit

Trait Implementations§

source§

impl Clone for ImperfectReadoutModel

source§

fn clone(&self) -> ImperfectReadoutModel

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ImperfectReadoutModel

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ImperfectReadoutModel

source§

fn default() -> ImperfectReadoutModel

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for ImperfectReadoutModel

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl From<ImperfectReadoutModel> for NoiseModel

source§

fn from(value: ImperfectReadoutModel) -> Self

Converts to this type from the input type.
source§

impl PartialEq for ImperfectReadoutModel

source§

fn eq(&self, other: &ImperfectReadoutModel) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for ImperfectReadoutModel

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl SupportedVersion for ImperfectReadoutModel

source§

fn minimum_supported_roqoqo_version(&self) -> (u32, u32, u32)

Returns the minimum roqoqo version that supports the operation. Read more
source§

impl StructuralPartialEq for ImperfectReadoutModel

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for T
where T: Clone,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,