TruncatedNormal

class TruncatedNormal(normalMean: Double, normalVariance: Double, interval: Interval, name: String? = null) : Distribution, ContinuousDistributionIfc, InverseCDFIfc, GetRVariableIfc

Creates a truncated normal distribution over the supplied interval. The supplied mean normalMean and variance normalVariance is the mean of the not truncated normal distribution. The supplied mean must be contained within the supplied interval.

Uses the algorithm:

  1. W ~ U(F(a), F(b))

  2. X = F^{-1}(W)

where "a" is the lower limit and b is the upper limit, and F is the normal distribution CDF.

Constructors

Link copied to clipboard
constructor(normal: Normal, interval: Interval, name: String? = null)
constructor(normalMean: Double, normalVariance: Double, interval: Interval, name: String? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val id: Int
Link copied to clipboard
Link copied to clipboard
open override var label: String?
Link copied to clipboard
Link copied to clipboard
open override val name: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Returns an array of probabilities each representing F(x_i). The CDF is evaluated for each point in the input array x and the probabilities are returned in the returned array.

open fun cdf(interval: Interval): Double

Returns the probability of being in the interval, F(upper limit) - F(lower limit) Be careful, this is Pr{lower limit < = X < = upper limit} which includes the lower limit and has implications if the distribution is discrete

open fun cdf(x1: Double, x2: Double): Double

Returns the Pr{x1 <= X <= x2} for the distribution. Be careful, this is Pr{x1 <= X <= x2} which includes the lower limit and has implications if the distribution is discrete

open override fun cdf(x: Double): Double

Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function

Link copied to clipboard

Computes the complementary cumulative probability distribution function for given value of x. This is P{X > x}

Link copied to clipboard
open override fun domain(): Interval
Link copied to clipboard
open override fun instance(): TruncatedNormal
Link copied to clipboard
open fun invCDF(probabilities: DoubleArray): DoubleArray

Computes x_p where P(X <= x_p) = p for the supplied array of probabilities. Requires that the values within the supplied array are in (0,1)

open override fun invCDF(p: Double): Double

Provides the inverse cumulative distribution function for the distribution

Link copied to clipboard
open fun likelihood(data: DoubleArray): Double

Assuming that the observations in the array data are from a random sample, this function computes the likelihood function. This is computed using as the sum of the log-likelihood function raised to e. Implementation may want to specify other computationally efficient formulas for this function or (most likely) the sum of the log-likelihood function.

Link copied to clipboard
open override fun logLikelihood(x: Double): Double

Computes the natural log of the pdf function evaluated at x. Implementations may want to specify computationally efficient formulas for this function.

Link copied to clipboard
open override fun mean(): Double

This is the mean of the truncated distribution.

Link copied to clipboard
open override fun parameters(): DoubleArray

Gets the parameters of the truncated distribution normal mean = parameter0 normal variance = parameters1 lower limit = parameters2 upper limit = parameters3

open override fun parameters(params: DoubleArray)

Sets the parameters of the truncated distribution normal mean = parameter0 normal variance = parameters1 lower limit = parameters2 upper limit = parameters3

Link copied to clipboard
open override fun pdf(x: Double): Double

Returns the f(x) where f represents the probability density function for the distribution. Note this is not a probability.

Link copied to clipboard
open override fun randomVariable(stream: RNStreamIfc): RVariableIfc
open fun randomVariable(streamNum: Int): RVariableIfc
Link copied to clipboard
fun setLimits(normalMean: Double, normalVariance: Double, interval: Interval)

Should be used to change the parameters of the distribution

fun setLimits(normalMean: Double, normalVariance: Double, lower: Double, upper: Double)

A convenience function for setting the parameters of the distribution.

Link copied to clipboard

Returns the standard deviation for the distribution as the square root of the variance if it exists

Link copied to clipboard

Computes the sum of the log-likelihood function evaluated at each observation in the data. Implementations may want to specify computationally efficient formulas for this function.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun variance(): Double

This is the variance of the truncated distribution.