"""Sample one fixed circuit with several shot budgets and random seeds."""

from __future__ import annotations

import json
from math import pi, sqrt

from cascaqit import Circuit


def experiment() -> dict[str, object]:
    circuit = Circuit(1).ry(pi / 3, 0).measure_all()
    rows = []
    for shots in (32, 128, 1024):
        frequencies = []
        for seed in (11, 22, 33, 44):
            result = circuit.run(shots=shots, seed=seed)
            frequencies.append(result.counts.get("1", 0) / shots)
        rows.append(
            {
                "shots": shots,
                "frequencies": frequencies,
                "binomial_standard_error": sqrt(0.25 * 0.75 / shots),
            }
        )
    return {"ideal_probability_one": 0.25, "seeds": [11, 22, 33, 44], "runs": rows}


if __name__ == "__main__":
    print(json.dumps(experiment(), sort_keys=True))
