"""Burst strategy based on the fraction of measured zero bits."""
from .burst import Burst
[docs]
class ZeroBurst(Burst):
r"""Return the fraction of measured bits equal to zero.
.. math::
\\text{Burst} =
\\frac{
\\text{Number of 0s for the state in the computational base}
}{
\\text{State dimension}
}
For example, for ``"00100100"`` we have :math:`\\frac{6}{8}`:
>>> from qrobot.bursts import ZeroBurst
>>> state = "00100100"
>>> ZeroBurst(state)
0.75
"""
def __call__(self, state: str) -> float:
"""Return the fraction of ``state`` characters equal to ``"0"``."""
return state.count("0") / len(state)