Class DistBernoulli
java.lang.Object
nl.tudelft.simulation.jstats.distributions.Dist
nl.tudelft.simulation.jstats.distributions.DistDiscrete
nl.tudelft.simulation.jstats.distributions.DistBernoulli
- All Implemented Interfaces:
Serializable
The Bernoulli distribution, with p as the probability for success. For more information on this distribution see
https://mathworld.wolfram.com/BernouilliDistribution.html
Copyright (c) 2002-2024 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://simulation.tudelft.nl. The DSOL project is distributed under a three-clause BSD-style license, which can be found at https://https://simulation.tudelft.nl/dsol/docs/latest/license.html.
- Author:
- Peter Jacobs , Alexander Verbraeck
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDistBernoulli
(StreamInterface stream, double p) constructs a new Bernoulli distribution, with p as the probability for success (X=1), where failure is associated with X=0. -
Method Summary
Modifier and TypeMethodDescriptionlong
draw()
draws the next value from the Bernoulli distribution.double
getP()
Return p, the probability for success (X=1), where failure is associated with X=0.double
probability
(long observation) returns the probability of the observation in this particular distribution.toString()
-
Constructor Details
-
DistBernoulli
constructs a new Bernoulli distribution, with p as the probability for success (X=1), where failure is associated with X=0.- Parameters:
stream
- StreamInterface; is the streamp
- double; the probability for success of the Bernoulli distribution- Throws:
IllegalArgumentException
- when p < 0 or p > 1
-
-
Method Details
-
draw
public long draw()draws the next value from the Bernoulli distribution. More information on this distribution can be found at
https://mathworld.wolfram.com/ BernoulliDistribution.html.- Specified by:
draw
in classDistDiscrete
- Returns:
- the next value {0,1}, where 1 denotes success (probability p), and 0 denotes failure (probability (1-p).
-
probability
public double probability(long observation) returns the probability of the observation in this particular distribution.- Specified by:
probability
in classDistDiscrete
- Parameters:
observation
- long; the discrete observation.- Returns:
- double the probability.
-
getP
public double getP()Return p, the probability for success (X=1), where failure is associated with X=0.- Returns:
- double; p, the probability for success (X=1)
-
toString
-