## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") options(width = 80) library(distributional) ## ----------------------------------------------------------------------------- dist <- dist_normal(mu = c(0, 3), sigma = c(1, 2)) dist ## ----------------------------------------------------------------------------- density(dist, at = 0) # broadcast density(dist, at = c(0, 1)) # mapped density(dist, at = list(d = c(0, 1))) # recycled ## ----------------------------------------------------------------------------- density(dist, 0) ## ----------------------------------------------------------------------------- density(dist, c(0, 1)) ## ----------------------------------------------------------------------------- quantile(dist_normal(0, 1), ppoints(5)) ## ----------------------------------------------------------------------------- dnorm(x = c(0, 1), mean = c(0, 3), sd = c(1, 2)) ## ----------------------------------------------------------------------------- density(dist, list(d = c(0, 1))) ## ----------------------------------------------------------------------------- cdf(dist, list(fixed = 0, varying = c(0, 1))) ## ----error = TRUE------------------------------------------------------------- try({ quantile(dist, list(p = c(0.1, 0.5, 0.9))) }) ## ----------------------------------------------------------------------------- dnorm(x = c(-1, 0, 2), mean = c(0, 3), sd = c(1, 2)) ## ----------------------------------------------------------------------------- mvn <- dist_multivariate_normal( mu = list(c(0, 0), c(3, 3)), sigma = list(diag(2), 2 * diag(2)) ) density(mvn, cbind(0, 0)) # 1-row matrix: broadcast density(mvn, cbind(c(0, 1), c(0, 1))) # 2-row matrix: mapped ## ----------------------------------------------------------------------------- density(mvn, list(d = cbind(c(0, 1), c(0, 1))))