Learn R Programming

algebraic.dist (version 0.9.1)

+.dist: Method for adding dist objects, or shifting a distribution by a scalar.

Description

Creates an expression distribution and automatically simplifies to closed form when possible (e.g., normal + normal = normal, normal + scalar = normal with shifted mean).

Usage

# S3 method for dist
+(x, y)

Value

A simplified distribution or edist if no closed form exists

Arguments

x

A dist object or numeric scalar

y

A dist object or numeric scalar

Examples

Run this code
# Sum of two normals simplifies to a normal
z <- normal(0, 1) + normal(2, 3)
z  # Normal(mu = 2, var = 4)

# Shift a distribution by a constant
normal(0, 1) + 5  # Normal(mu = 5, var = 1)

Run the code above in your browser using DataLab