deep_causality_rand/errors/
bernoulli_error.rs

1/*
2 * SPDX-License-Identifier: MIT
3 * Copyright (c) "2025" . The DeepCausality Authors and Contributors. All Rights Reserved.
4 */
5use core::fmt;
6
7#[derive(Clone, Copy, Debug, PartialEq, Eq)]
8pub enum BernoulliDistributionError {
9    /// `p < 0` or `p > 1`.
10    InvalidProbability,
11}
12
13impl std::error::Error for BernoulliDistributionError {}
14
15impl fmt::Display for BernoulliDistributionError {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        f.write_str(match self {
18            BernoulliDistributionError::InvalidProbability => {
19                "p is outside [0, 1] in Bernoulli distribution"
20            }
21        })
22    }
23}