Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Convolution

Distribution Convolution Wrapper


Description

Calculates the convolution of two distribution via numerical calculations.

Usage

## S3 method for class 'Distribution'
x + y

## S3 method for class 'Distribution'
x - y

Arguments

Details

The convolution of two probability distributions X, Y is the sum

Z = X + Y

which has a pmf,

P(Z = z) = ∑_x P(X = x)P(Y = z - x)

with an integration analogue for continuous distributions.

Currently distr6 supports the addition of discrete and continuous probability distributions, but only subtraction of continuous distributions.

Value

Returns an R6 object of class Convolution.

Super classes

Methods

Public methods


Method new()

Creates a new instance of this R6 class.

Usage
Convolution$new(dist1, dist2, add = TRUE)
Arguments
dist1

([Distribution])
First Distribution in convolution, i.e. dist1 ± dist2.

dist2

([Distribution])
Second Distribution in convolution, i.e. dist1 ± dist2.

add

(logical(1))
If TRUE (default) then adds the distributions together, otherwise substracts.


Method clone()

The objects of this class are cloneable with this method.

Usage
Convolution$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

Examples

binom <- Bernoulli$new() + Bernoulli$new()
binom$pdf(2)
Binomial$new(size = 2)$pdf(2)
norm <- Normal$new(mean = 3) - Normal$new(mean = 2)
norm$pdf(1)
Normal$new(mean = 1, var = 2)$pdf(1)

distr6

The Complete R6 Probability Distributions Interface

v1.5.2
MIT + file LICENSE
Authors
Raphael Sonabend [aut, cre] (<https://orcid.org/0000-0001-9225-4654>), Franz Kiraly [aut], Peter Ruckdeschel [ctb] (Author of distr), Matthias Kohl [ctb] (Author of distr), Nurul Ain Toha [ctb], Shen Chen [ctb], Jordan Deenichin [ctb], Chengyang Gao [ctb], Chloe Zhaoyuan Gu [ctb], Yunjie He [ctb], Xiaowen Huang [ctb], Shuhan Liu [ctb], Runlong Yu [ctb], Chijing Zeng [ctb], Qian Zhou [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.