# Noise Reconstruction (NR)¶

The effective noise under Randomized Compiling (RC) is a Pauli channel, that is, a channel that maps a state \(\rho\) to

for some probability distribution \(\mu\) over the \(N\)-qubit Pauli group.

Through noise reconstruction (NR), we can reconstruct the probability distribution \(\mu\) using carefully targeted Cycle Benchmarking (CB) diagnostic sequences with additional post-processing.

We have two noise reconstruction protocols:

- K-body Noise Reconstruction (KNR)
Performs noise reconstruction on various subsets of qudits which are most relevant to the cycle being benchmarked, returning error probabilities for every Pauli in each subset. See

`make_knr()`

for details.- Targeted Noise Reconstruction (TMR)
Performs noise reconstruction for a targeted set of Pauli errors, returning error probabilities for user-specified Pauli errors. See

`make_tnr()`

for details.

## KNR Example¶

```
#
# K-body noise reconstruction (KNR) example.
# Copyright 2019 Quantum Benchmark Inc.
#
import trueq as tq
# Define the cycle we wish to do noise reconstruction on.
cycle = {(label,): tq.Gate.id for label in range(4)}
# Generate a circuit collection to measure noise.
circuits = tq.make_knr(cycle, [4, 32, 64], 30)
# Initialize a simulator with stochastic pauli noise.
sim = tq.Simulator().add_stochastic_pauli(px=0.005, py=0.005)
# Run the circuits on the simulator to populate the results.
sim.run(circuits)
# Plot the results.
circuits.plot().nr_bar()
```

## TNR Example¶

```
#
# Targeted noise reconstruction (TNR) example.
# Copyright 2019 Quantum Benchmark Inc.
#
import trueq as tq
# Define the cycle we wish to do noise reconstruction on.
cycle = {(label,): tq.Gate.id for label in range(4)}
# Generate a circuit collection to measure noise.
circuits = tq.make_tnr(cycle, [4, 32, 64], 30, targeted_errors={"XXXX", "XYXY", "YYZZ"})
# Initialize a simulator with stochastic pauli noise.
sim = tq.Simulator().add_stochastic_pauli(px=0.005, py=0.005)
# Run the circuits on the simulator to populate the results.
sim.run(circuits)
# Plot the results.
circuits.plot().nr_cmap()
```