R/SDistribution_Arrdist.R
sub-.Arrdist.Rd
Extract a WeightedDiscrete or Matdist or Arrdist from a Arrdist.
# S3 method for class 'Arrdist'
ad[i = NULL, j = NULL]
Arrdist from which to extract Distributions.
indices specifying distributions (first dimension) to extract, all returned if NULL.
indices specifying curves (third dimension) to extract, all returned if NULL.
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
.
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)