View source: R/as.Distribution.R
as.Distribution | R Documentation |
Coerces matrices to a VectorDistribution containing
WeightedDiscrete distributions or a Matdist. Number of distributions
are the number of rows in the matrix, number of x
points are number of
columns in the matrix.
as.Distribution(obj, fun, decorators = NULL, vector = FALSE) ## S3 method for class 'matrix' as.Distribution(obj, fun, decorators = NULL, vector = FALSE)
obj |
matrix. Column names correspond to |
fun |
Either |
decorators |
Passed to VectorDistribution or Matdist. |
vector |
|
A VectorDistribution or Matdist
pdf <- runif(200) mat <- matrix(pdf, 20, 10, FALSE, list(NULL, 1:10)) mat <- t(apply(mat, 1, function(x) x / sum(x))) # coercion to matrix distribution as.Distribution(mat, fun = "pdf") # coercion to vector of weighted discrete distributions as.Distribution(mat, fun = "pdf", vector = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.