# Options for more complex error models on stim?

We're trying to simulate whether some initialization strings are preferable to others. For example, would initializing all qubits to $$|0\rangle$$ lead to a lower error rate?

Is it possible to further tune the error model to allow for, for example, a higher probability of a bit-flip when the qubit is in $$|1\rangle$$ rather than $$|0\rangle$$?

Stim circuits don't have a native option for this kind of error model, because it's incompatible with some of the key performance optimizations used for high speed bulk sampling.

However, you can do this sort of thing by directly driving stim.TableauSimulator. For example, after telling the tableau simulator to do a layer of operations, you could roll dice to decide whether or not to apply resets:

from typing import Sequence
import random
import stim

def apply_decay_error(sim: stim.TableauSimulator,
decay_probability: float,
affected_qubits: Sequence[int]):
decayed_qubits = [
q
for q in affected_qubits
if random.random() < decay_probability
]

# Note: much more efficient to reset all in one call
sim.reset(*decayed_qubits)


Directly using stim.TableauSimulator produces samples orders of magnitude slower than stim.Circuit.compile_sampler would, but it's much more flexible.

• Thank you, Craig! This is very detailed and helpful. Jul 7 at 23:30