if (FALSE) {
# a uniform parameter constrained to be between 0 and 1
phi <- uniform(min = 0, max = 1)
# a length-three variable, with each element following a standard normal
# distribution
alpha <- normal(0, 1, dim = 3)
# a length-three variable of lognormals
sigma <- lognormal(0, 3, dim = 3)
# a hierarchical uniform, constrained between alpha and alpha + sigma,
eta <- alpha + uniform(0, 1, dim = 3) * sigma
# a hierarchical distribution
mu <- normal(0, 1)
sigma <- lognormal(0, 1)
theta <- normal(mu, sigma)
# a vector of 3 variables drawn from the same hierarchical distribution
thetas <- normal(mu, sigma, dim = 3)
# a matrix of 12 variables drawn from the same hierarchical distribution
thetas <- normal(mu, sigma, dim = c(3, 4))
# a multivariate normal variable, with correlation between two elements
# note that the parameter must be a row vector
Sig <- diag(4)
Sig[3, 4] <- Sig[4, 3] <- 0.6
theta <- multivariate_normal(t(rep(mu, 4)), Sig)
# 10 independent replicates of that
theta <- multivariate_normal(t(rep(mu, 4)), Sig, n_realisations = 10)
# 10 multivariate normal replicates, each with a different mean vector,
# but the same covariance matrix
means <- matrix(rnorm(40), 10, 4)
theta <- multivariate_normal(means, Sig, n_realisations = 10)
dim(theta)
# a Wishart variable with the same covariance parameter
theta <- wishart(df = 5, Sigma = Sig)
}
Run the code above in your browser using DataLab