Defines a Binomial random variable. It uses in the backend
all functions that defines a Binomial
random variable. As
the other definitions in distributions
this is an
R6
object. Tha parametrization used
is from a $$X \sim \mathsf{Binomial}(n, \theta)\,,$$
where the parameters \(n\) and \(\theta\) are
the number of independent trials and the rate (probability) of success.
Note
All random variables in distributions
are defined as R6
objects. The fields
(referenced below) are needed for objects of
R6::R6Class
. In our context these are what defines
which specific instance of a
random variable is used. That is, the public fields
are the
parameters of the random variable \(\theta \in \mathbb{R}^p\), for some
\(p\).
See also
Other discrete:
PoissonRandomVariable
Public fields
n
(
integer
)
the number of independent trials, \(n\).theta
(
double
, constrained)
the probability of success of an independent trial, \(\theta \in [0,1]\).
Methods
Method new()
Generates a Binomial DiscreteRandomVariable
object with specified
number of trials (n
) and probability of success (theta
).
Usage
BinomialRandomVariable$new(n = 10, theta = 0.5)
Method sample()
Generates random variables using the stats::rbinom()
function.
Method density()
Evaluates the density function using the stats::dbinom()
function.