from common import counting_counts, phase_estimation, phase_gate

from qsim import ONE

phi = 1 / 3
for t in (4, 5):
    predicted = round(phi * 2**t)
    counts = counting_counts(phase_estimation(phase_gate(phi), ONE, t), t, shots=1000, seed=42)
    best = max(counts, key=counts.get)
    print(f"t = {t} : prévu {predicted:0{t}b}, le plus fréquent {best} ({counts[best]} sur 1000)")
