resize: Resize

Description Usage Arguments Value Examples

View source: R/dist.R

Description

Generic function to resize the support of the distribution in place. If the distribution shrinks, the last lenght(Dist) - n elements are lost, the rest are preserved. If it grows, the last n - lenght(Dist) elements are zeroed.

Usage

1
resize(d, n)

Arguments

d

Dist object representing the distribution.

n

Numeric representing the desired size of the support.

Value

Dist giving the resized distribution.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Resizing invalid distribution
d <- Dist(5)
d <- resize(d, 3)
length(d) # 3

d <- resize(d, 8)
length(d) # 8

# Resizing valid distribution
d <- Dist(c(1, 2, 3, 4))
d <- resize(d, 2) # list(c(1, 2), 2, 3)
d
d <- resize(d, 4) # list(c(1, 2, 0, 0), 4, 3)
d

rinform documentation built on April 1, 2018, 12:12 p.m.