# Probabilistic Programming

**URL:** https://discourse.julialang.org/c/domain/probprog/48.md?page=13

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

**Page:** 14

---

## [Manually defined partially conjugate update step](https://discourse.julialang.org/t/manually-defined-partially-conjugate-update-step/51299)

<div class="topic-metadata">

**Author:** [@fmeulen](https://discourse.julialang.org/u/fmeulen)\
**Replies:** 2\
**Last updated:** [December 9, 2020, 8:05pm UTC](https://discourse.julialang.org/t/manually-defined-partially-conjugate-update-step/51299 "2020-12-09T20:05:05Z")

</div>

I have a model where I can apply Turing to the full parameter vector, that seems to work. However, I can partition the parameter such that a Gibbs sampler can be devised where one parameter is updated in a partially conj…

---

## [Spaces for "base measures"](https://discourse.julialang.org/t/spaces-for-base-measures/50594)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 11\
**Last updated:** [December 3, 2020, 4:01pm UTC](https://discourse.julialang.org/t/spaces-for-base-measures/50594 "2020-12-03T16:01:41Z")

</div>

For MeasureTheory.jl, we need a nice way to represent some domains, like continuous sets ℝ, ℝ₊, and 𝕀 (unit interval) Infinite discrete sets ℤ, ℤ₊, ℤ₀₊ Also finite sets a:b, but that’s easier Eventually we’ll need to…

---

## [Rand/logpdf semantic consistency](https://discourse.julialang.org/t/rand-logpdf-semantic-consistency/50904)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 12\
**Last updated:** [December 3, 2020, 1:07am UTC](https://discourse.julialang.org/t/rand-logpdf-semantic-consistency/50904 "2020-12-03T01:07:54Z")

</div>

There’s a subtle issue I’ve mentioned before involving rand and logpdf that has gotten in the way of composability. I’m thinking in terms of Soss and MeasureTheory.jl, but I thought I’d post here since it may be helpful …

---

## [Gaussian Process Model with Turing](https://discourse.julialang.org/t/gaussian-process-model-with-turing/42453)

<div class="topic-metadata">

**Author:** [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Replies:** 84\
**Last updated:** [November 28, 2020, 6:12pm UTC](https://discourse.julialang.org/t/gaussian-process-model-with-turing/42453 "2020-11-28T18:12:19Z")

</div>

Is it possible to specifiy a Gaussian process (GP) regression model directly in Turing? I’ve looked at Stheno.jl and GaussianProcesses.jl, but neither have an obvious way to specify a multivariate model (GaussianProcesse…

---

## [Repeatedly calculating likelihood using Turing](https://discourse.julialang.org/t/repeatedly-calculating-likelihood-using-turing/50608)

<div class="topic-metadata">

**Author:** [@ArnoStrouwen](https://discourse.julialang.org/u/ArnoStrouwen)\
**Replies:** 2\
**Last updated:** [November 27, 2020, 8:56pm UTC](https://discourse.julialang.org/t/repeatedly-calculating-likelihood-using-turing/50608 "2020-11-27T20:56:36Z")

</div>

I want to repeatedly calculate likelihoods of the same Turing model at different parameter values, and also with different possible observations. What is the best way to do this in Turing? A minimal example of the type o…

---

## [Speed up model in Turing](https://discourse.julialang.org/t/speed-up-model-in-turing/50555)

<div class="topic-metadata">

**Author:** [@ohmsweetohm1](https://discourse.julialang.org/u/ohmsweetohm1)\
**Replies:** 1\
**Last updated:** [November 21, 2020, 10:46pm UTC](https://discourse.julialang.org/t/speed-up-model-in-turing/50555 "2020-11-21T22:46:30Z")

</div>

Note that I am new to Turing as well as to Bayesian inference. I have to following simple Bayesian linear regression model. (This is pretty much the tutorial example) Turing.@model function linear\_regression(x, y) …

---

## [Turing: Observing sum of two random dice](https://discourse.julialang.org/t/turing-observing-sum-of-two-random-dice/50486)

<div class="topic-metadata">

**Author:** [@Hakan\_Kjellerstrand](https://discourse.julialang.org/u/Hakan_Kjellerstrand)\
**Replies:** 4\
**Last updated:** [November 21, 2020, 8:29am UTC](https://discourse.julialang.org/t/turing-observing-sum-of-two-random-dice/50486 "2020-11-21T08:29:03Z")

</div>

I’m (still) a Turing beginner and tries to build some simple models (porting my WebPPL models). I now wonder how observing a sum of two (DiscreteUniform) random variables works, i.e. to force the sum to a specific value. …

---

## [Issue querying probabilities using chain](https://discourse.julialang.org/t/issue-querying-probabilities-using-chain/50383)

<div class="topic-metadata">

**Author:** [@michielver](https://discourse.julialang.org/u/michielver)\
**Replies:** 6\
**Last updated:** [November 19, 2020, 8:18am UTC](https://discourse.julialang.org/t/issue-querying-probabilities-using-chain/50383 "2020-11-19T08:18:23Z")

</div>

Hi, This is my first post, so I will try to make it as clear as possible, otherwise point out anything that is unclear. I am running into an issue with querying probabilities using chains. I tried to reduce it to as sm…

---

## [How to get better performance from NUTS in Turing?](https://discourse.julialang.org/t/how-to-get-better-performance-from-nuts-in-turing/50349)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 0\
**Last updated:** [November 18, 2020, 12:54am UTC](https://discourse.julialang.org/t/how-to-get-better-performance-from-nuts-in-turing/50349 "2020-11-18T00:54:32Z")

</div>

I’m wondering if anyone has further performance tips to speed this up? This MWE is an attempt to use NUTS on data that is similar in size to my actual use case, following the model introduced in this post, but no longer…

---

## [Random walks inside a model](https://discourse.julialang.org/t/random-walks-inside-a-model/49994)

<div class="topic-metadata">

**Author:** [@Camilo1704](https://discourse.julialang.org/u/Camilo1704)\
**Replies:** 4\
**Last updated:** [November 17, 2020, 8:49am UTC](https://discourse.julialang.org/t/random-walks-inside-a-model/49994 "2020-11-17T08:49:02Z")

</div>

Hi guys, I’m wondering if there is a way to include a variable which is a random walk in a model. Particularly, if inside my model I have the lines of code shown below, is there a walk around to do it more efficiently? …

---

## [Resources for developing probabilistic models? Not syntax, but conceptually](https://discourse.julialang.org/t/resources-for-developing-probabilistic-models-not-syntax-but-conceptually/49501)

<div class="topic-metadata">

**Author:** [@dcgrigsby](https://discourse.julialang.org/u/dcgrigsby)\
**Replies:** 8\
**Last updated:** [November 14, 2020, 7:16am UTC](https://discourse.julialang.org/t/resources-for-developing-probabilistic-models-not-syntax-but-conceptually/49501 "2020-11-14T07:16:25Z")

</div>

I’m interested in creating probabilistic models. Here’s context to frame my question: I’ve got enough adjacent experience to be able to understand tutorials/examples for simple Turing and Gen models for things like co…

---

## [Specify a separate MvNormal for each observation of a variable in Turing](https://discourse.julialang.org/t/specify-a-separate-mvnormal-for-each-observation-of-a-variable-in-turing/50081)

<div class="topic-metadata">

**Author:** [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Replies:** 2\
**Last updated:** [November 13, 2020, 3:32pm UTC](https://discourse.julialang.org/t/specify-a-separate-mvnormal-for-each-observation-of-a-variable-in-turing/50081 "2020-11-13T15:32:42Z")

</div>

This MWE is eq.6 from Kyung et al. which features group-wise scaling of the coefficients to facilitate shrinkage, analogous to the grouped lasso. Pretty sure I just messed up the model specification somehow but I also f…

---

## [Some question about the structure of Turing models](https://discourse.julialang.org/t/some-question-about-the-structure-of-turing-models/48211)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 25\
**Last updated:** [November 6, 2020, 6:07pm UTC](https://discourse.julialang.org/t/some-question-about-the-structure-of-turing-models/48211 "2020-11-06T18:07:42Z")

</div>

Hello, given a Turing model @model function λ(y) λ₁ ~ Exponential(alpha) for i in 1:length(y) y\[i\] ~ Poisson(λ₁) end end what is the meaning of the y array? I think it is used to compute the post…

---

## [Is it possible to implement custom inference in Turing?](https://discourse.julialang.org/t/is-it-possible-to-implement-custom-inference-in-turing/48468)

<div class="topic-metadata">

**Author:** [@yarnton](https://discourse.julialang.org/u/yarnton)\
**Replies:** 1\
**Last updated:** [October 23, 2020, 1:45pm UTC](https://discourse.julialang.org/t/is-it-possible-to-implement-custom-inference-in-turing/48468 "2020-10-23T13:45:44Z")

</div>

I’m new to Turing, but I have quite a lot of experience in probabilistic programming. Particularly with models that can be expressed as factor graphs (e.g. Infer NET or ForneyLab.jl). Turing looks really neat. Is it rea…

---

## [Define a distribution from a given distribution](https://discourse.julialang.org/t/define-a-distribution-from-a-given-distribution/48220)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 12\
**Last updated:** [October 16, 2020, 8:55am UTC](https://discourse.julialang.org/t/define-a-distribution-from-a-given-distribution/48220 "2020-10-16T08:55:23Z")

</div>

Hello, I would like to define two distributions: p = Uniform(0,1) p2 = 1-p give me typrerror. ERROR: MethodError: no method matching -(::Int64, ::Uniform{Float64}) I also cannot sum two distributions: c = Normal(…

---

## [List of resources using Turing](https://discourse.julialang.org/t/list-of-resources-using-turing/47784)

<div class="topic-metadata">

**Author:** [@mystis](https://discourse.julialang.org/u/mystis)\
**Replies:** 2\
**Last updated:** [October 5, 2020, 3:23pm UTC](https://discourse.julialang.org/t/list-of-resources-using-turing/47784 "2020-10-05T15:23:30Z")

</div>

Hi everyone, I thought it would nice to have a “Learning” section for Turing, something similar to what exists on the Julialang website. I know there are tutorials and links to Statistical Rethinking but I thought that …

---

## [Turing type error: expected Float64, got ForwardDiff.Dual](https://discourse.julialang.org/t/turing-type-error-expected-float64-got-forwarddiff-dual/47670)

<div class="topic-metadata">

**Author:** [@mangulo](https://discourse.julialang.org/u/mangulo)\
**Replies:** 9\
**Last updated:** [October 3, 2020, 5:14pm UTC](https://discourse.julialang.org/t/turing-type-error-expected-float64-got-forwarddiff-dual/47670 "2020-10-03T17:14:26Z")

</div>

Hi All, I’m trying to do a multivariable linear regression y = \\Phi(A, x) using Turing, where y \\in \\mathbb R^N, x \\in \\mathbb R^N, and the function \\Phi is linear in the unknown parameters A \\in \\mathbb R^{N \\times N}.…

---

## [WAIC, or LOO etc in Turing?](https://discourse.julialang.org/t/waic-or-loo-etc-in-turing/30873)

<div class="topic-metadata">

**Author:** [@aammd](https://discourse.julialang.org/u/aammd)\
**Replies:** 11\
**Last updated:** [October 1, 2020, 8:16pm UTC](https://discourse.julialang.org/t/waic-or-loo-etc-in-turing/30873 "2020-10-01T20:16:19Z")

</div>

Hello everyone, I was wondering if any of the popular model selection criteria have been implemented in Turing? for example WAIC or LOO, etc? I am surprised that I can’t find mention of these in this forum or in the doc…

---

## [Choosing the "best" sampler](https://discourse.julialang.org/t/choosing-the-best-sampler/47605)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 1\
**Last updated:** [October 1, 2020, 4:50pm UTC](https://discourse.julialang.org/t/choosing-the-best-sampler/47605 "2020-10-01T16:50:01Z")

</div>

Hello, I would like to know how shoud I choose the sampler given a model (using the Turing framework). I haven’t found information in the official guide. Could you suggest me something to read about that related to th…

---

## [Vectorizing observations from multivariate distribution in Turing](https://discourse.julialang.org/t/vectorizing-observations-from-multivariate-distribution-in-turing/47436)

<div class="topic-metadata">

**Author:** [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Replies:** 1\
**Last updated:** [September 30, 2020, 9:06pm UTC](https://discourse.julialang.org/t/vectorizing-observations-from-multivariate-distribution-in-turing/47436 "2020-09-30T21:06:31Z")

</div>

I have a model where the data are drawn from multinomial distributions. The parameters of those distributions (number of draws and probabilities) are different at each data point. MWE below: ndata = 100 k = 5 n = 10 p…

---

## [\[Resolved\] Return in @model](https://discourse.julialang.org/t/resolved-return-in-model/47140)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 4\
**Last updated:** [September 25, 2020, 1:59pm UTC](https://discourse.julialang.org/t/resolved-return-in-model/47140 "2020-09-25T13:59:10Z")

</div>

Hello, I would like to know what is the meaning of the return statement in a @model block in Turing. In the documentation only some example use return in the model definition. The samples generation works as well witho…

---

## [Different samples distribution after execution](https://discourse.julialang.org/t/different-samples-distribution-after-execution/47077)

<div class="topic-metadata">

**Author:** [@mcql](https://discourse.julialang.org/u/mcql)\
**Replies:** 5\
**Last updated:** [September 24, 2020, 3:14pm UTC](https://discourse.julialang.org/t/different-samples-distribution-after-execution/47077 "2020-09-24T15:14:57Z")

</div>

Hello, I wrote a this simple Turing model: @model function λ(y) lambda1 ~ Exponential(alpha) lambda2 ~ Exponential(alpha) τ ~ Uniform(1, n\_count\_data) for i in 1:length(y) y\[i\] ~ Poisson(τ \> i ?…

---

## [Community call notes 09/20](https://discourse.julialang.org/t/community-call-notes-09-20/47208)

<div class="topic-metadata">

**Author:** [@McCoy](https://discourse.julialang.org/u/McCoy)\
**Replies:** 1\
**Last updated:** [September 24, 2020, 1:58pm UTC](https://discourse.julialang.org/t/community-call-notes-09-20/47208 "2020-09-24T13:58:59Z")

</div>

Just so we get broad coverage - if you took notes, you might share them here as well (@mohamed82008, @cscherrer, @phg) Also, here are the collected links from the chat: From Alex: From Chad: https://julialang.zulip…

---

## [Custom priors in Soss](https://discourse.julialang.org/t/custom-priors-in-soss/47076)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 6\
**Last updated:** [September 23, 2020, 8:23pm UTC](https://discourse.julialang.org/t/custom-priors-in-soss/47076 "2020-09-23T20:23:40Z")

</div>

On Slack, Jonatan Werpers asks, How can I use a custom prior with a model? Basically I want to do something like: my\_pdf(θ) = .... m = @model n begin θ ~ my\_pdf x ~ Bernoulli(θ) |\> iid(n) end Generally, you’…

---

## [Julia PPL survey paper?](https://discourse.julialang.org/t/julia-ppl-survey-paper/44879)

<div class="topic-metadata">

**Author:** [@cscherrer](https://discourse.julialang.org/u/cscherrer)\
**Replies:** 15\
**Last updated:** [September 22, 2020, 8:29pm UTC](https://discourse.julialang.org/t/julia-ppl-survey-paper/44879 "2020-09-22T20:29:02Z")

</div>

Would it be feasible for the Julia PPL community to collaborate on a survey article? It could cover things like Why Julia is great for PPL Overview of current approaches and the general design space Opportunities for “…

---

## [GP-LVM with Turing?](https://discourse.julialang.org/t/gp-lvm-with-turing/47007)

<div class="topic-metadata">

**Author:** [@opera\_malenky](https://discourse.julialang.org/u/opera_malenky)\
**Replies:** 5\
**Last updated:** [September 21, 2020, 5:52pm UTC](https://discourse.julialang.org/t/gp-lvm-with-turing/47007 "2020-09-21T17:52:54Z")

</div>

I saw some of the recent posts these last few weeks about implementing gaussian processes in Turing. I’ve really been wanting to play around with GP-LVMs for a while (in particular, as part of a larger model), so I took …

---

## [Help speeding up and reducing numerical errors for simple epidemic model with Turing.jl](https://discourse.julialang.org/t/help-speeding-up-and-reducing-numerical-errors-for-simple-epidemic-model-with-turing-jl/46614)

<div class="topic-metadata">

**Author:** [@MFairley](https://discourse.julialang.org/u/MFairley)\
**Replies:** 9\
**Last updated:** [September 21, 2020, 3:42pm UTC](https://discourse.julialang.org/t/help-speeding-up-and-reducing-numerical-errors-for-simple-epidemic-model-with-turing-jl/46614 "2020-09-21T15:42:26Z")

</div>

I’m trying to fit a simple epidemic model that starts at some unknown time and then the prevalence of infection progresses according to a logistic curve. The data provided are Binomial with a known sample size. I generat…

---

## [Model updating: Using previously computed posterior as prior after new data acquisition](https://discourse.julialang.org/t/model-updating-using-previously-computed-posterior-as-prior-after-new-data-acquisition/46869)

<div class="topic-metadata">

**Author:** [@Camilo1704](https://discourse.julialang.org/u/Camilo1704)\
**Replies:** 3\
**Last updated:** [September 18, 2020, 8:38pm UTC](https://discourse.julialang.org/t/model-updating-using-previously-computed-posterior-as-prior-after-new-data-acquisition/46869 "2020-09-18T20:38:51Z")

</div>

Hi guys! I’m working with some models using a bayesian framework (Soss and Turing). I was wondering, once I have already contrasted my prior with the data and obtained the posterior distribution, how to add more data and…

---

## [When to use Tarrays](https://discourse.julialang.org/t/when-to-use-tarrays/46758)

<div class="topic-metadata">

**Author:** [@Elmo](https://discourse.julialang.org/u/Elmo)\
**Replies:** 3\
**Last updated:** [September 17, 2020, 7:10pm UTC](https://discourse.julialang.org/t/when-to-use-tarrays/46758 "2020-09-17T19:10:31Z")

</div>

Hi everyone, I’m new to Turing/probabilistic programming and would like to know when you should use TArrays vs. normal arrays in the model definition. The package guidelines mention that “stack allocated variables” are…

---

## [Amortized Hierarchical Variational Model](https://discourse.julialang.org/t/amortized-hierarchical-variational-model/46665)

<div class="topic-metadata">

**Author:** [@darleybarreto](https://discourse.julialang.org/u/darleybarreto)\
**Replies:** 4\
**Last updated:** [September 17, 2020, 2:49pm UTC](https://discourse.julialang.org/t/amortized-hierarchical-variational-model/46665 "2020-09-17T14:49:16Z")

</div>

Suppose I have a complex neural network giving four parameters mu, precision, alpha, beta, which may be fixed for all training, learned during training or varying for each batch, such as: X,Y = next\_batch(data) (mu,prec…

[Previous page](https://discourse.julialang.org/c/domain/probprog/48.md?page=12)

[Next page](https://discourse.julialang.org/c/domain/probprog/48.md?page=14)
