---
title: StabilizerState (v1.2)
description: API reference for qiskit.quantum_info.StabilizerState in qiskit v1.2
source: https://eu-de.quantum.cloud.ibm.com/docs/en/api/qiskit/1.2/qiskit.quantum_info.StabilizerState
---

# StabilizerState

*class* `qiskit.quantum_info.StabilizerState(data, validate=True)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L32-L773)

Bases: `QuantumState`

StabilizerState class. Stabilizer simulator using the convention from reference \[1]. Based on the internal class [`Clifford`](/docs/api/qiskit/1.2/qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford").

```python
from qiskit import QuantumCircuit
from qiskit.quantum_info import StabilizerState, Pauli

# Bell state generation circuit
qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
stab = StabilizerState(qc)

# Print the StabilizerState
print(stab)

# Calculate the StabilizerState measurement probabilities dictionary
print (stab.probabilities_dict())

# Calculate expectation value of the StabilizerState
print (stab.expectation_value(Pauli('ZZ')))
```

```python
StabilizerState(StabilizerTable: ['+XX', '+ZZ'])
{'00': 0.5, '11': 0.5}
1
```

Given a list of stabilizers, [`qiskit.quantum_info.StabilizerState.from_stabilizer_list()`](#qiskit.quantum_info.StabilizerState.from_stabilizer_list "qiskit.quantum_info.StabilizerState.from_stabilizer_list") returns a state stabilized by the list

```python
from qiskit.quantum_info import StabilizerState

stabilizer_list = ["ZXX", "-XYX", "+ZYY"]
stab = StabilizerState.from_stabilizer_list(stabilizer_list)
```

**References**

1. S. Aaronson, D. Gottesman, *Improved Simulation of Stabilizer Circuits*, Phys. Rev. A 70, 052328 (2004). [arXiv:quant-ph/0406196](https://arxiv.org/abs/quant-ph/0406196)

Initialize a StabilizerState object.

**Parameters**

- **or** (*data (*[*StabilizerState*](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")  *or*[*Clifford*](/docs/api/qiskit/1.2/qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford")  *or*[*Pauli*](/docs/api/qiskit/1.2/qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")  *or*[*QuantumCircuit*](/docs/api/qiskit/1.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")) – qiskit.circuit.Instruction): Data from which the stabilizer state can be constructed.
- **validate** (*boolean*) – validate that the stabilizer state data is a valid Clifford.

## Attributes

### clifford

Return StabilizerState Clifford data

### dim

Return total state dimension.

### num\_qubits

Return the number of qubits if a N-qubit state or None otherwise.

## Methods

### conjugate

`conjugate()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L191-L195)

Return the conjugate of the operator.

### copy

`copy()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/quantum_state.py#L74-L76)

Make a copy of current operator.

### dims

`dims(qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/quantum_state.py#L70-L72)

Return tuple of input dimension for specified subsystems.

### equiv

`equiv(other)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L322-L361)

Return True if the two generating sets generate the same stabilizer group.

**Parameters**

**other** ([*StabilizerState*](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")) – another StabilizerState.

**Returns**

True if other has a generating set that generates the same StabilizerState.

**Return type**

[bool](https://docs.python.org/3/library/functions.html#bool)

### evolve

`evolve(other, qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L233-L255)

Evolve a stabilizer state by a Clifford operator.

**Parameters**

- **other** ([*Clifford*](/docs/api/qiskit/1.2/qiskit.quantum_info.Clifford "qiskit.quantum_info.Clifford")  *or*[*QuantumCircuit*](/docs/api/qiskit/1.2/qiskit.circuit.QuantumCircuit "qiskit.circuit.QuantumCircuit")  *or*[*qiskit.circuit.Instruction*](/docs/api/qiskit/1.2/qiskit.circuit.Instruction "qiskit.circuit.Instruction")) – The Clifford operator to evolve by.
- **qargs** ([*list*](https://docs.python.org/3/library/stdtypes.html#list)) – a list of stabilizer subsystem positions to apply the operator on.

**Returns**

the output stabilizer state.

**Return type**

[StabilizerState](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")

**Raises**

- [**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if other is not a StabilizerState.
- [**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if the operator dimension does not match the specified StabilizerState subsystem dimensions.

### expand

`expand(other)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L215-L231)

Return the tensor product stabilizer state other ⊗ self.

**Parameters**

**other** ([*StabilizerState*](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")) – a stabilizer state object.

**Returns**

the tensor product operator other ⊗ self.

**Return type**

[StabilizerState](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")

**Raises**

[**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if other is not a StabilizerState.

### expectation\_value

`expectation_value(oper, qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L257-L320)

Compute the expectation value of a Pauli operator.

**Parameters**

- **oper** ([*Pauli*](/docs/api/qiskit/1.2/qiskit.quantum_info.Pauli "qiskit.quantum_info.Pauli")) – a Pauli operator to evaluate expval.
- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to apply the operator on.

**Returns**

the expectation value (only 0 or 1 or -1 or i or -i).

**Return type**

[complex](https://docs.python.org/3/library/functions.html#complex)

**Raises**

[**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if oper is not a Pauli operator.

### from\_stabilizer\_list

*classmethod* `from_stabilizer_list(stabilizers, allow_redundant=False, allow_underconstrained=False)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L108-L136)

Create a stabilizer state from the collection of stabilizers.

**Parameters**

- **stabilizers** (*Collection\[*[*str*](https://docs.python.org/3/library/stdtypes.html#str)*]*) – list of stabilizer strings
- **allow\_redundant** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – allow redundant stabilizers (i.e., some stabilizers can be products of the others)
- **allow\_underconstrained** ([*bool*](https://docs.python.org/3/library/functions.html#bool)) – allow underconstrained set of stabilizers (i.e., the stabilizers do not specify a unique state)

**Returns**

a state stabilized by stabilizers.

**Return type**

[StabilizerState](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")

### is\_valid

`is_valid(atol=None, rtol=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L149-L151)

Return True if a valid StabilizerState.

### measure

`measure(qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L486-L514)

Measure subsystems and return outcome and post-measure state.

Note that this function uses the QuantumStates internal random number generator for sampling the measurement outcome. The RNG seed can be set using the [`seed()`](#qiskit.quantum_info.StabilizerState.seed "qiskit.quantum_info.StabilizerState.seed") method.

**Parameters**

**qargs** ([*list*](https://docs.python.org/3/library/stdtypes.html#list) *or None*) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

**Returns**

**the pair `(outcome, state)` where `outcome` is the**

measurement outcome string label, and `state` is the collapsed post-measurement stabilizer state for the corresponding outcome.

**Return type**

[tuple](https://docs.python.org/3/library/stdtypes.html#tuple)

### probabilities

`probabilities(qargs=None, decimals=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L363-L387)

Return the subsystem measurement probability vector.

Measurement probabilities are with respect to measurement in the computation (diagonal) basis.

**Parameters**

- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to return probabilities for, if None return for all subsystems (Default: None).
- **decimals** (*None or* [*int*](https://docs.python.org/3/library/functions.html#int)) – the number of decimal places to round values. If None no rounding is done (Default: None).

**Returns**

The Numpy vector array of probabilities.

**Return type**

np.array

### probabilities\_dict

`probabilities_dict(qargs=None, decimals=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L425-L447)

Return the subsystem measurement probability dictionary.

Measurement probabilities are with respect to measurement in the computation (diagonal) basis.

This dictionary representation uses a Ket-like notation where the dictionary keys are qudit strings for the subsystem basis vectors. If any subsystem has a dimension greater than 10 comma delimiters are inserted between integers so that subsystems can be distinguished.

**Parameters**

- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to return probabilities for, if None return for all subsystems (Default: None).
- **decimals** (*None or* [*int*](https://docs.python.org/3/library/functions.html#int)) – the number of decimal places to round values. If None no rounding is done (Default: None).

**Returns**

The measurement probabilities in dict (key) form.

**Return type**

[dict](https://docs.python.org/3/library/stdtypes.html#dict)

### probabilities\_dict\_from\_bitstring

`probabilities_dict_from_bitstring(outcome_bitstring, qargs=None, decimals=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L389-L423)

Return the subsystem measurement probability dictionary utilizing a targeted outcome\_bitstring to perform the measurement for. This will calculate a probability for only a single targeted outcome\_bitstring value, giving a performance boost over calculating all possible outcomes.

Measurement probabilities are with respect to measurement in the computation (diagonal) basis.

This dictionary representation uses a Ket-like notation where the dictionary keys are qudit strings for the subsystem basis vectors. If any subsystem has a dimension greater than 10 comma delimiters are inserted between integers so that subsystems can be distinguished.

**Parameters**

- **outcome\_bitstring** (*None or* [*str*](https://docs.python.org/3/library/stdtypes.html#str)) – targeted outcome bitstring to perform a measurement calculation for, this will significantly reduce the number of calculation performed (Default: None)
- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to return probabilities for, if None return for all subsystems (Default: None).
- **decimals** (*None or* [*int*](https://docs.python.org/3/library/functions.html#int)) – the number of decimal places to round values. If None no rounding is done (Default: None)

**Returns**

The measurement probabilities in dict (ket) form.

**Return type**

[dict](https://docs.python.org/3/library/stdtypes.html#dict)\[[str](https://docs.python.org/3/library/stdtypes.html#str), [float](https://docs.python.org/3/library/functions.html#float)]

### purity

`purity()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L173-L185)

Return the purity of the quantum state, which equals to 1, since it is always a pure state.

**Returns**

the purity (should equal 1).

**Return type**

[float](https://docs.python.org/3/library/functions.html#float)

**Raises**

[**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if input is not a StabilizerState.

### reset

`reset(qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L449-L484)

Reset state or subsystems to the 0-state.

**Parameters**

**qargs** ([*list*](https://docs.python.org/3/library/stdtypes.html#list) *or None*) – subsystems to reset, if None all subsystems will be reset to their 0-state (Default: None).

**Returns**

the reset state.

**Return type**

[StabilizerState](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")

**Additional Information:**

If all subsystems are reset this will return the ground state on all subsystems. If only some subsystems are reset this function will perform a measurement on those subsystems and evolve the subsystems so that the collapsed post-measurement states are rotated to the 0-state. The RNG seed for this sampling can be set using the [`seed()`](#qiskit.quantum_info.StabilizerState.seed "qiskit.quantum_info.StabilizerState.seed") method.

### sample\_counts

`sample_counts(shots, qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/quantum_state.py#L277-L304)

Sample a dict of qubit measurement outcomes in the computational basis.

**Parameters**

- **shots** ([*int*](https://docs.python.org/3/library/functions.html#int)) – number of samples to generate.
- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

**Returns**

sampled counts dictionary.

**Return type**

[Counts](/docs/api/qiskit/1.2/qiskit.result.Counts "qiskit.result.Counts")

Additional Information:

> This function *samples* measurement outcomes using the measure [`probabilities()`](#qiskit.quantum_info.StabilizerState.probabilities "qiskit.quantum_info.StabilizerState.probabilities") for the current state and qargs. It does not actually implement the measurement so the current state is not modified.
>
> The seed for random number generator used for sampling can be set to a fixed value by using the stats [`seed()`](#qiskit.quantum_info.StabilizerState.seed "qiskit.quantum_info.StabilizerState.seed") method.

### sample\_memory

`sample_memory(shots, qargs=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L516-L540)

Sample a list of qubit measurement outcomes in the computational basis.

**Parameters**

- **shots** ([*int*](https://docs.python.org/3/library/functions.html#int)) – number of samples to generate.
- **qargs** (*None or* [*list*](https://docs.python.org/3/library/stdtypes.html#list)) – subsystems to sample measurements for, if None sample measurement of all subsystems (Default: None).

**Returns**

list of sampled counts if the order sampled.

**Return type**

np.array

Additional Information:

> This function implements the measurement [`measure()`](#qiskit.quantum_info.StabilizerState.measure "qiskit.quantum_info.StabilizerState.measure") method.
>
> The seed for random number generator used for sampling can be set to a fixed value by using the stats [`seed()`](#qiskit.quantum_info.StabilizerState.seed "qiskit.quantum_info.StabilizerState.seed") method.

### seed

`seed(value=None)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/quantum_state.py#L78-L85)

Set the seed for the quantum state RNG.

### tensor

`tensor(other)`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L197-L213)

Return the tensor product stabilizer state self ⊗ other.

**Parameters**

**other** ([*StabilizerState*](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")) – a stabilizer state object.

**Returns**

the tensor product operator self ⊗ other.

**Return type**

[StabilizerState](#qiskit.quantum_info.StabilizerState "qiskit.quantum_info.StabilizerState")

**Raises**

[**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if other is not a StabilizerState.

### to\_operator

`to_operator()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L187-L189)

Convert state to matrix operator class

**Return type**

[*Operator*](/docs/api/qiskit/1.2/qiskit.quantum_info.Operator "qiskit.quantum_info.operators.operator.Operator")

### trace

`trace()`

[GitHub](https://github.com/Qiskit/qiskit/tree/stable/1.2/qiskit/quantum_info/states/stabilizerstate.py#L159-L171)

Return the trace of the stabilizer state as a density matrix, which equals to 1, since it is always a pure state.

**Returns**

the trace (should equal 1).

**Return type**

[float](https://docs.python.org/3/library/functions.html#float)

**Raises**

[**QiskitError**](/docs/api/qiskit/1.2/exceptions#qiskit.exceptions.QiskitError "qiskit.exceptions.QiskitError") – if input is not a StabilizerState.
