DistBernoulli
- class pydsol.core.distributions.DistBernoulli(stream: StreamInterface, p: float)[source]
Bases:
DistDiscrete
The Bernoulli distribution is a discrete distribution function with a single trial with a probability p for success (X = 1) and a probability 1-p for failure (X = 0).
- __init__(stream: StreamInterface, p: float)[source]
Constructs a new Bernoulli distribution, with p as the probability for success (X=1), where failure is associated with X=0.
- Parameters:
stream (StreamInterface) – the random stream to use for this distribution
p (float) – the probability for success of the Bernoulli distribution
- Raises:
TypeError – when stream is not implementing StreamInterface:
TypeError – when p is not a float:
ValueError – when p < 0 or p > 1:
- draw() int [source]
Draw a value from the Bernoulli distribution, where 1 denotes success (probability p) and 0 indicates failure (probability 1 - p).
- probability(observation: int) float [source]
Returns the probability of the observation for the distribution.
- property p: float
Return the parameter value p
- property stream: StreamInterface
Return the current random stream for this distribution.