Learn R Programming

algebraic.dist (version 0.9.1)

-.dist: Method for negation or subtraction of dist objects.

Description

Unary: returns negated distribution (e.g., -N(mu, var) = N(-mu, var)) Binary: creates expression distribution and simplifies to closed form when possible (e.g., normal - normal = normal, normal - scalar = normal).

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 (optional for unary negation)

Examples

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

# Unary negation
-normal(3, 1)  # Normal(mu = -3, var = 1)

Run the code above in your browser using DataLab