Learn R Programming

distr6 (version 1.6.9)

[.Matdist: Extract one or more Distributions from a Matdist

Description

Extract a WeightedDiscrete or Matdist from a Matdist.

Usage

# S3 method for Matdist
[(md, i)

Arguments

md

Matdist from which to extract Distributions.

i

indices specifying distributions to extract.

Value

If length(i) == 1 then returns a WeightedDiscrete otherwise returns a Matdist.

Examples

Run this code
# NOT RUN {
m <- as.Distribution(
  t(apply(matrix(runif(200), 20, 10, FALSE,
                  list(NULL, sort(sample(1:20, 10)))), 1,
          function(x) x / sum(x))),
  fun = "pdf"
)
m[1]
m[1:2]
# }

Run the code above in your browser using DataLab