Extract a WeightedDiscrete or Matdist or Arrdist from a Arrdist.

# S3 method for class 'Arrdist'
ad[i = NULL, j = NULL]

Arguments

ad

Arrdist from which to extract Distributions.

i

indices specifying distributions (first dimension) to extract, all returned if NULL.

j

indices specifying curves (third dimension) to extract, all returned if NULL.

Value

If length(i) == 1 and length(j) == 1 then returns a WeightedDiscrete otherwise if j is NULL returns an Arrdist. If length(i) is greater than 1 or NULL returns a Matdist if length(j) == 1.

Examples

pdf <- runif(400)
arr <- array(pdf, c(20, 10, 2), list(NULL, sort(sample(1:20, 10)), NULL))
arr <- aperm(apply(arr, c(1, 3), function(x) x / sum(x)), c(2, 1, 3))
darr <- as.Distribution(arr, fun = "pdf")
# WeightDisc
darr[1, 1]
#> WeightDisc(10) 
# Matdist
darr[1:2, 1]
#> Matdist(2x10) 
# Arrdist
darr[1:3, 1:2]
#> Arrdist(3x10x2) 
darr[1, 1:2]
#> Arrdist(1x10x2)