quara.math.probability module

validate_prob_dist(prob_dist, eps=None, validate_sum=True, raise_error=True, message='')[source]

validate the probability distribution.

Parameters
  • prob_dist (np.ndarray) – the probability distribution.

  • eps (float, optional) – the absolute tolerance parameter, by default 1e-8. checks absolute(the sum of probabilities - 1) <= atol in this function.

  • validate_sum (bool, optional) – whether to validate sum=1, by default True.

  • raise_error (bool, optional) – raises error when validation fails, by default True.

  • message (str, optional) – prints additional message when validation fails, by default “”.

Raises
  • ValueError – some elements of prob_dist are negative numbers.

  • ValueError – the sum of prob_dist is not 1.

Return type

None