# cirq.validate_probability¶

cirq.validate_probability(p: float, p_str: str) → float[source]

Validates that a probability is between 0 and 1 inclusively.

Parameters
• p – The value to validate.

• p_str – What to call the probability in error messages.

Returns

The probability p if the probability if valid.

Raises

ValueError if the probability is invalid.