Skip to contents

Arithmetic operators and functions for probability distribution objects. These methods define how standard operations like +, -, *, and / behave when applied to random variables, returning the resulting distribution based on known properties of common distribution families.

Usage

# S4 method for class 'Norm,Norm'
e1 + e2

# S4 method for class 'numeric,Norm'
e1 + e2

# S4 method for class 'Norm,numeric'
e1 + e2

# S4 method for class 'Norm,Norm'
e1 - e2

# S4 method for class 'numeric,Norm'
e1 - e2

# S4 method for class 'Norm,numeric'
e1 - e2

# S4 method for class 'numeric,Norm'
e1 * e2

# S4 method for class 'Norm,numeric'
e1 * e2

# S4 method for class 'Norm,numeric'
e1/e2

# S4 method for class 'Norm,logical'
sum(x, ..., na.rm = FALSE)

# S4 method for class 'Norm'
exp(x)

Arguments

x, e1, e2

objects of subclass Distribution.

...

extra arguments.

na.rm

logical. Should missing values be removed?

Value

All calculations return Distribution objects (specifically, objects of a class that is a subclass of Distribution), according to the property at hand.

Examples

# -----------------------------------------------------
# Distribution Calculus Example
# -----------------------------------------------------

# Normal location - scale transformation
x <- Norm(2, 3)
y <- 3 * x + 1 # Norm(7, 9)

# Addition of two independent Normal random variables
x1 <- Norm(1, 3)
x2 <- Norm(2, 4)
x3 <- x1 + x2 # Norm(3, 5)