Learn R Programming

greta (version 0.1.3)

greta: greta: Probabilistic Modelling with TensorFlow

Description

greta lets you write probabilistic models interactively in native R code, then sample from them efficiently using Hamiltonian Monte Carlo.

The computational heavy lifting is done by TensorFlow, Google's automatic differentiation library. greta is particularly fast where the model contains lots of linear algebra, and greta models can be easily set up to run across CPUs or GPUs just by installing the relevant version of TensorFlow.

See the example below for the general set up of a greta model, and greta-distributions, greta-operators, greta-functions, greta-transforms and greta-structures for details of the currently implemented syntax and how to combine them into models

Arguments

Examples

Run this code
## Not run: ------------------------------------
# # define a simple model
# mu = free()
# sigma = lognormal(1, 0.1)
# x = rnorm(10)
# likelihood(x) =  normal(mu, sigma)
# 
# m <- define_model(mu, sigma)
# 
# # and sample from it
# draws <- mcmc(m,
#               n_samples = 100,
#               warmup = 10)
## ---------------------------------------------

Run the code above in your browser using DataLab