def get_average_fidelitiy(get_error_process): lvls = [3, 3] Lambda = get_error_process d = 4 err = tf_super(Lambda) choi = super_to_choi(err) chi = tf_choi_to_chi(choi, dims=lvls) fid = tf_abs((chi[0, 0] / d + 1) / (d + 1)) return fid
def orbit_infid( U_dict, RB_number: int = 30, RB_length: int = 20, lindbladian=False, shots: int = None, seqs=None, noise=None ): if not seqs: seqs = single_length_RB(RB_number=RB_number, RB_length=RB_length) Us = evaluate_sequences(U_dict, seqs) infids = [] for U in Us: dim = int(U.shape[0]) psi_init = tf.constant(basis(dim, 0), dtype=tf.complex128) psi_actual = tf.matmul(U, psi_init) pop0 = tf_abs(psi_actual[0])**2 p1 = 1 - pop0 if shots: vals = tf.keras.backend.random_binomial( [shots], p=p1, dtype=tf.float64, ) # if noise: # vals = vals + (np.random.randn(shots) * noise) infid = tf.reduce_mean(vals) else: infid = p1 # if noise: # infid = infid + (np.random.randn() * noise) if noise: infid = infid + (np.random.randn() * noise) infids.append(infid) return tf_ave(infids)