# This is a nice 2d probability distribution nice2d <- " parameters { real x; real y; } model { x ~ normal(0,1); y ~ normal(0,1); } " nice_model <- stan(model_code = nice2d) # This is a much more challenging 2d distribution for stan slow2d <- " parameters { real x; real y; } model { x ~ normal(0,10); y - x^2 ~ normal(0,1); } " slow_model <- stan(model_code = slow2d) # Here is a bimodal distribution bimodal1d <- " functions { // the log pdf of a sum of two normal pdfs, centered at 0 and 8 real custom_bimodal_lpdf(real x) { return log_sum_exp(normal_lpdf(x | 0,1), normal_lpdf(x | 8,1)); } } parameters { real theta; } model { theta ~ custom_bimodal(); } " bim_model <- stan(model_code = bimodal1d)