Skip to content

Defines a Normal random variable. It uses in the backend all functions that defines a Gaussian random variable. As the other definitions in distributions this is an R6 object. Tha parametrization used is from a $$X \sim \mathsf{Normal}(\mu, \sigma)\,,$$ where the parameters \(\mu\) and \(\sigma\) are the mean and standard deviation, respectively.

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

Super class

distributions::ContinuousRandomVariable -> Gaussian

Public fields

mean

(double)
the center of the distribution, \(\mu\).

sd

(double, positive)
the dispersion around the mean, \(\sigma \geq 0\).

Methods


Method new()

Generates a Gaussian ContinuousRandomVariable object with specified mean (mean) and standard deviation (sd).

Usage

GaussianRandomVariable$new(mean = 0, sd = 1)

Arguments

mean

(double) the center of the distribution.

sd

(double, positive) the dispersion around the center of the distribution.


Method sample()

Generates random variables using the stats::rnorm() function.

Usage

GaussianRandomVariable$sample(nsamples = 1, nreps = 1)

Arguments

nsamples

(integer) the number of random numbers being generated that behaves like the random variables.

nreps

(integer) the number of sequences of size nsamples to be generated.

Returns

(array) of random numbers from the distribution.


Method density()

Evaluates the density function using the stats::dnorm() function.

Usage

GaussianRandomVariable$density(x, log = TRUE)

Arguments

x

(array) to evaluate the density function.

log

(Boolean) indicates if we are evaluating the log-density.

Returns

(array) of evaluations at x.