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