# Probabilistic Programming

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

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

**Page:** 6

---

## [Posterior prediction in Turing](https://discourse.julialang.org/t/posterior-prediction-in-turing/97355)

<div class="topic-metadata">

**Author:** [@jfhawkin](https://discourse.julialang.org/u/jfhawkin)\
**Replies:** 4\
**Last updated:** [April 13, 2023, 6:10pm UTC](https://discourse.julialang.org/t/posterior-prediction-in-turing/97355 "2023-04-13T18:10:09Z")

</div>

I’m looking to replicate the below code snippet from a Stan example. I’m having a hard time figuring out the syntax to replicate the Turing predict() example for my logistic regression model and translating the Stan code…

---

## [Getting Turing to work with a hierarchical multinomial regression model](https://discourse.julialang.org/t/getting-turing-to-work-with-a-hierarchical-multinomial-regression-model/97386)

<div class="topic-metadata">

**Author:** [@Matan](https://discourse.julialang.org/u/Matan)\
**Replies:** 2\
**Last updated:** [April 12, 2023, 4:09pm UTC](https://discourse.julialang.org/t/getting-turing-to-work-with-a-hierarchical-multinomial-regression-model/97386 "2023-04-12T16:09:48Z")

</div>

Hi everyone, I’m sorry if this question is too specific. I tried following advice in previous similar threads but couldn’t get anything to work, so figured I should try asking myself. For context, I’m modeling 5000 Han…

---

## [Porting multi-level regression with poststratification (MRP) tutorial from rstanarm](https://discourse.julialang.org/t/porting-multi-level-regression-with-poststratification-mrp-tutorial-from-rstanarm/96689)

<div class="topic-metadata">

**Author:** [@jfhawkin](https://discourse.julialang.org/u/jfhawkin)\
**Replies:** 7\
**Last updated:** [April 5, 2023, 10:15pm UTC](https://discourse.julialang.org/t/porting-multi-level-regression-with-poststratification-mrp-tutorial-from-rstanarm/96689 "2023-04-05T22:15:08Z")

</div>

I am working to port a tutorial on MRP from rstanarm to Turing. I’m also just getting started on Julia, so it’s an opportunity to learn the language at the same time. I’ve estimated a few models in Stan and have some fa…

---

## [Turing.jl: unlikely posterior with bayesian differential equation?](https://discourse.julialang.org/t/turing-jl-unlikely-posterior-with-bayesian-differential-equation/92269)

<div class="topic-metadata">

**Author:** [@Janssena](https://discourse.julialang.org/u/Janssena)\
**Replies:** 9\
**Last updated:** [April 4, 2023, 6:46am UTC](https://discourse.julialang.org/t/turing-jl-unlikely-posterior-with-bayesian-differential-equation/92269 "2023-04-04T06:46:44Z")

</div>

Hey All, I am trying to approximate the posterior distribution of a random variable inside of a differential equation with a stochastic outcome. I am able to sample from the posterior distribution, I am however unsure i…

---

## [GLM model from statistical rethinking video series](https://discourse.julialang.org/t/glm-model-from-statistical-rethinking-video-series/96666)

<div class="topic-metadata">

**Author:** [@arthings](https://discourse.julialang.org/u/arthings)\
**Replies:** 0\
**Last updated:** [March 27, 2023, 4:59pm UTC](https://discourse.julialang.org/t/glm-model-from-statistical-rethinking-video-series/96666 "2023-03-27T16:59:45Z")

</div>

Hello, i have an issue with the Turing code related to this model in the Statistical Rethinking video series. This code is not in the book so i didn’t find the solution in the good ressourcesTuringModels.jl or SR2TuringP…

---

## [Problems fitting a simple Multinomial model in RxInfer](https://discourse.julialang.org/t/problems-fitting-a-simple-multinomial-model-in-rxinfer/95442)

<div class="topic-metadata">

**Author:** [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)\
**Replies:** 5\
**Last updated:** [March 26, 2023, 2:33pm UTC](https://discourse.julialang.org/t/problems-fitting-a-simple-multinomial-model-in-rxinfer/95442 "2023-03-26T14:33:10Z")

</div>

Hello everyone, I’m experimenting with the awesome package RxInfer but apparently I’m having some difficulties in understanding some basic principles. I tried to adapt one of the first simple examples of RxInfer to bui…

---

## [How to solve Path Integral Problems with Probabilistic Programming Techniques?](https://discourse.julialang.org/t/how-to-solve-path-integral-problems-with-probabilistic-programming-techniques/96430)

<div class="topic-metadata">

**Author:** [@GDufenshuoo](https://discourse.julialang.org/u/GDufenshuoo)\
**Replies:** 8\
**Last updated:** [March 22, 2023, 2:45pm UTC](https://discourse.julialang.org/t/how-to-solve-path-integral-problems-with-probabilistic-programming-techniques/96430 "2023-03-22T14:45:34Z")

</div>

Hello everyone, I’m not very familiar with probabilistic programming, so I may not be approaching this problem in the most optimal way. Essentially, I’m trying to solve a problem of the following form: Z \\sim \\int\\int..…

---

## [Score function error for simple custom Gaussian node in RxInfer](https://discourse.julialang.org/t/score-function-error-for-simple-custom-gaussian-node-in-rxinfer/96368)

<div class="topic-metadata">

**Author:** [@John\_Boik](https://discourse.julialang.org/u/John_Boik)\
**Replies:** 1\
**Last updated:** [March 22, 2023, 12:46pm UTC](https://discourse.julialang.org/t/score-function-error-for-simple-custom-gaussian-node-in-rxinfer/96368 "2023-03-22T12:46:05Z")

</div>

I’m testing a simple Gaussian custom node in RxInfer just to make sure I have the syntax correct, but I’m having trouble with the score function for Bethe free energy. My inference() function runs fine and returns BFE if…

---

## [Use of update!() in RXInfer to handle multiple iterations](https://discourse.julialang.org/t/use-of-update-in-rxinfer-to-handle-multiple-iterations/95709)

<div class="topic-metadata">

**Author:** [@John\_Boik](https://discourse.julialang.org/u/John_Boik)\
**Replies:** 12\
**Last updated:** [March 14, 2023, 4:35pm UTC](https://discourse.julialang.org/t/use-of-update-in-rxinfer-to-handle-multiple-iterations/95709 "2023-03-14T16:35:05Z")

</div>

I am trying to implement the van de Laar chance constraint model in RXInfer, and as a warm-up I have implemented the reference model from the same paper. Code is included at the end of this post that produces an output g…

---

## [How to implement a model with missing observations in Turing?](https://discourse.julialang.org/t/how-to-implement-a-model-with-missing-observations-in-turing/95572)

<div class="topic-metadata">

**Author:** [@AdamR](https://discourse.julialang.org/u/AdamR)\
**Replies:** 6\
**Last updated:** [March 12, 2023, 12:04pm UTC](https://discourse.julialang.org/t/how-to-implement-a-model-with-missing-observations-in-turing/95572 "2023-03-12T12:04:13Z")

</div>

I would like to write in Julia the following toy Bernoulli model written in JAGS: model{ p0 ~ dbeta(1,1) for(i in 1:n){ y\[i\] ~ dbern(p0) } } Here’s the complete driver true\_p0 \<- 0.2 n \<- 600 y \<- sampl…

---

## [Fit Gaussian process to training points](https://discourse.julialang.org/t/fit-gaussian-process-to-training-points/90841)

<div class="topic-metadata">

**Author:** [@jar1](https://discourse.julialang.org/u/jar1)\
**Replies:** 7\
**Last updated:** [January 14, 2023, 7:01pm UTC](https://discourse.julialang.org/t/fit-gaussian-process-to-training-points/90841 "2023-01-14T19:01:22Z")

</div>

For self-study I am trying to fit a GP according to the formula in the GPML book I am able to draw some random functions from the prior distribution, but when I try to condition on the data it seems to make no differ…

---

## [Searching for words: @model xxx(n) vs model = xxx(17)](https://discourse.julialang.org/t/searching-for-words-model-xxx-n-vs-model-xxx-17/95230)

<div class="topic-metadata">

**Author:** [@zenon](https://discourse.julialang.org/u/zenon)\
**Replies:** 2\
**Last updated:** [February 28, 2023, 9:05pm UTC](https://discourse.julialang.org/t/searching-for-words-model-xxx-n-vs-model-xxx-17/95230 "2023-02-28T21:05:06Z")

</div>

In Turing, we have one thing called model, the thing constructed with the @model macro. Like @model myModel(X; n = 1) m ~ Normal(100.0, 5.0) s ~ Exponential(1.0) X ~ filldist(Normal(m, s), n) end But then,…

---

## [Error using pmap on autodiff ODE solver inside Turing @model function](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449)

<div class="topic-metadata">

**Author:** [@mjmcnelis](https://discourse.julialang.org/u/mjmcnelis)\
**Replies:** 9\
**Last updated:** [February 23, 2023, 4:53pm UTC](https://discourse.julialang.org/t/error-using-pmap-on-autodiff-ode-solver-inside-turing-model-function/94449 "2023-02-23T16:53:53Z")

</div>

Our group is interested in fitting unknown parameters in our multi-physics model using the variational inference package AdvancedVI. To fit the parameters, we use experimental data from multiple tests and run a dynamical…

---

## [How to (if possible) re-write this simple censored Poisson model without Turing.@addlogprob!](https://discourse.julialang.org/t/how-to-if-possible-re-write-this-simple-censored-poisson-model-without-turing-addlogprob/94902)

<div class="topic-metadata">

**Author:** [@AdamR](https://discourse.julialang.org/u/AdamR)\
**Replies:** 13\
**Last updated:** [February 22, 2023, 12:19am UTC](https://discourse.julialang.org/t/how-to-if-possible-re-write-this-simple-censored-poisson-model-without-turing-addlogprob/94902 "2023-02-22T00:19:10Z")

</div>

I want to estimate the Poisson distribution parameter λ (usually λ \< 1). I am given N observations, however they are censored: I can only see if the value was 0 or greater than zero, i.e. Instead of observing the vector…

---

## [Minibatch ADVI?](https://discourse.julialang.org/t/minibatch-advi/94985)

<div class="topic-metadata">

**Author:** [@spragud2](https://discourse.julialang.org/u/spragud2)\
**Replies:** 0\
**Last updated:** [February 21, 2023, 11:40pm UTC](https://discourse.julialang.org/t/minibatch-advi/94985 "2023-02-21T23:40:33Z")

</div>

Hey! I am trying to train a last-layer bayesian approximation for a neural network. The issue I am running in to is that ADVI tries to take the gradient of the entire dataset… obviously not going to work. Can the ADVI …

---

## [Error with ForwardDiff in Turing](https://discourse.julialang.org/t/error-with-forwarddiff-in-turing/88633)

<div class="topic-metadata">

**Author:** [@astro-kevin](https://discourse.julialang.org/u/astro-kevin)\
**Replies:** 30\
**Last updated:** [February 15, 2023, 12:19pm UTC](https://discourse.julialang.org/t/error-with-forwarddiff-in-turing/88633 "2023-02-15T12:19:34Z")

</div>

When running the sample method from Turing, I run into this error MethodError: no method matching Float64(::ForwardDiff.Dual{ForwardDiff.Tag{Turing.TuringTag, Float64}, Float64, 9}) Closest candidates are: (::Type{T}…

---

## [Probability queries for simple model](https://discourse.julialang.org/t/probability-queries-for-simple-model/93661)

<div class="topic-metadata">

**Author:** [@goretkin](https://discourse.julialang.org/u/goretkin)\
**Replies:** 5\
**Last updated:** [February 14, 2023, 1:35pm UTC](https://discourse.julialang.org/t/probability-queries-for-simple-model/93661 "2023-02-14T13:35:38Z")

</div>

I’d like both of the queries below to return 0.5. using Turing @model function foo(w) w ~ Categorical(\[0.5, 0.5\]) x = w + 1 end model = foo(missing) println(prob"w = 2 | model = model") println(prob"x = 3 | m…

---

## [Case study: Speeding up a logistic regression with RHS prior (Turing vs Numpyro) - any tricks I'm missing?](https://discourse.julialang.org/t/case-study-speeding-up-a-logistic-regression-with-rhs-prior-turing-vs-numpyro-any-tricks-im-missing/87681)

<div class="topic-metadata">

**Author:** [@svilupp](https://discourse.julialang.org/u/svilupp)\
**Replies:** 38\
**Last updated:** [February 6, 2023, 7:34pm UTC](https://discourse.julialang.org/t/case-study-speeding-up-a-logistic-regression-with-rhs-prior-turing-vs-numpyro-any-tricks-im-missing/87681 "2023-02-06T19:34:06Z")

</div>

Inspired by the recent long discussion on Slack around the performance of Turing, I’ve decided to try to beat my go-to implementation in Numpyro (and failed). I’d appreciate any tips or tricks on how to further speed up…

---

## [Models with persistent memory usage](https://discourse.julialang.org/t/models-with-persistent-memory-usage/93215)

<div class="topic-metadata">

**Author:** [@pfarndt](https://discourse.julialang.org/u/pfarndt)\
**Replies:** 3\
**Last updated:** [February 6, 2023, 5:12pm UTC](https://discourse.julialang.org/t/models-with-persistent-memory-usage/93215 "2023-02-06T17:12:16Z")

</div>

I am using Turing a lot but now I have a model which would keep some persistent memory to be computational efficient. A minimal example would be: using Turing, Optim, ForwardDiff mutable struct Acomputer{T \<: Number} …

---

## [AdaptiveMCMC defining prior and multivariate parameters](https://discourse.julialang.org/t/adaptivemcmc-defining-prior-and-multivariate-parameters/93917)

<div class="topic-metadata">

**Author:** [@astro-kevin](https://discourse.julialang.org/u/astro-kevin)\
**Replies:** 0\
**Last updated:** [February 2, 2023, 11:46am UTC](https://discourse.julialang.org/t/adaptivemcmc-defining-prior-and-multivariate-parameters/93917 "2023-02-02T11:46:11Z")

</div>

I’m trying to make a start on making a MCMC chain using AdaptiveMCMC. I’ve figured out a function which returns a log-likelihood given a specific set of parameters (a vector of parameters). I’m not quite sure how this go…

---

## [ForwardDiff AD Error using distributed within Turing @model](https://discourse.julialang.org/t/forwarddiff-ad-error-using-distributed-within-turing-model/93111)

<div class="topic-metadata">

**Author:** [@abhishek-venket](https://discourse.julialang.org/u/abhishek-venket)\
**Replies:** 0\
**Last updated:** [January 17, 2023, 7:17pm UTC](https://discourse.julialang.org/t/forwarddiff-ad-error-using-distributed-within-turing-model/93111 "2023-01-17T19:17:00Z")

</div>

I am trying to estimate the posterior distributions of a couple of parameters of a system of ODEs. The probabilistic model is data ~ MvNormal(y\_sim, σ² \* I), where data contains sensor measurements of a quantity of inte…

---

## [Sampling gives chains which converge to two different distributions in ODE example of TuringTutorials](https://discourse.julialang.org/t/sampling-gives-chains-which-converge-to-two-different-distributions-in-ode-example-of-turingtutorials/92734)

<div class="topic-metadata">

**Author:** [@Manuel\_Eguia](https://discourse.julialang.org/u/Manuel_Eguia)\
**Replies:** 4\
**Last updated:** [January 11, 2023, 12:54am UTC](https://discourse.julialang.org/t/sampling-gives-chains-which-converge-to-two-different-distributions-in-ode-example-of-turingtutorials/92734 "2023-01-11T00:54:31Z")

</div>

I was trying to sample the posterior for the parameters and initial condition of a very simple ODE taking the example from https://turing.ml/v0.21/tutorials/10-bayesian-differential-equations/ as a model, and I was alw…

---

## [How to model Zero Inflated Distribution](https://discourse.julialang.org/t/how-to-model-zero-inflated-distribution/92325)

<div class="topic-metadata">

**Author:** [@Guilherme\_Namen\_Pime](https://discourse.julialang.org/u/Guilherme_Namen_Pime)\
**Replies:** 2\
**Last updated:** [January 3, 2023, 12:38pm UTC](https://discourse.julialang.org/t/how-to-model-zero-inflated-distribution/92325 "2023-01-03T12:38:21Z")

</div>

Hi. How to programing a Zero Inflated Distribution using Turing?

---

## [Turing.jl setting different updates for arrays of variables](https://discourse.julialang.org/t/turing-jl-setting-different-updates-for-arrays-of-variables/92330)

<div class="topic-metadata">

**Author:** [@dariogasbarra](https://discourse.julialang.org/u/dariogasbarra)\
**Replies:** 2\
**Last updated:** [December 30, 2022, 8:44pm UTC](https://discourse.julialang.org/t/turing-jl-setting-different-updates-for-arrays-of-variables/92330 "2022-12-30T20:44:46Z")

</div>

Hello I have a model which has an array of discrete binary parameters J\[t\] and an array of continuous parameters X\[t\]. I want to use NUTS() or HMC() updates for the continuous variables and MH() updates for the dis…

---

## [Translating a TuringGLM model to a Turing model](https://discourse.julialang.org/t/translating-a-turingglm-model-to-a-turing-model/91818)

<div class="topic-metadata">

**Author:** [@PeetoomHeida](https://discourse.julialang.org/u/PeetoomHeida)\
**Replies:** 4\
**Last updated:** [December 25, 2022, 7:31pm UTC](https://discourse.julialang.org/t/translating-a-turingglm-model-to-a-turing-model/91818 "2022-12-25T19:31:59Z")

</div>

I am trying to implement a hierarchical model, and am running into issues getting the model to return the parameters I used to generate a test data set. When I implement the model using TuringGLM I get the parameters I e…

---

## [Issues implementing Copula regression using copula and Turing](https://discourse.julialang.org/t/issues-implementing-copula-regression-using-copula-and-turing/90907)

<div class="topic-metadata">

**Author:** [@Kokora](https://discourse.julialang.org/u/Kokora)\
**Replies:** 23\
**Last updated:** [December 10, 2022, 4:23pm UTC](https://discourse.julialang.org/t/issues-implementing-copula-regression-using-copula-and-turing/90907 "2022-12-10T16:23:49Z")

</div>

I am trying to implement a copula regression model by leveraging Turing and copulas in Julia. The author of copula implemented a nice working example as below using Copulas, Distributions, Random, Turing, Plots, StatsP…

---

## [MethodError: no method matching translate! in Turing with SMC](https://discourse.julialang.org/t/methoderror-no-method-matching-translate-in-turing-with-smc/91115)

<div class="topic-metadata">

**Author:** [@jtraffic](https://discourse.julialang.org/u/jtraffic)\
**Replies:** 0\
**Last updated:** [December 1, 2022, 9:25pm UTC](https://discourse.julialang.org/t/methoderror-no-method-matching-translate-in-turing-with-smc/91115 "2022-12-01T21:25:50Z")

</div>

Here is my full code, based on a Turing tutorial. using Turing, Turing.RandomMeasures using LinearAlgebra, Distributions using Plots, Random, CSV, DataFrames share\_1 = rand(Uniform(), 100) share\_2 = 1 .- share\_1 shar…

---

## [Turing Sampling specified parameters](https://discourse.julialang.org/t/turing-sampling-specified-parameters/90360)

<div class="topic-metadata">

**Author:** [@astro-kevin](https://discourse.julialang.org/u/astro-kevin)\
**Replies:** 40\
**Last updated:** [November 28, 2022, 3:44pm UTC](https://discourse.julialang.org/t/turing-sampling-specified-parameters/90360 "2022-11-28T15:44:35Z")

</div>

In my model, I have @model function runmodel(stuff, parameters) predictions, otherstuff = model(stuff, parameters) obs, var = findobsvar(stuff, otherstuff) obs ~ MvNormal(predictions, Diagonal(var)) where findobsvar is…

---

## [Performance issues sampling a multimomial logit (slightly modified) with Turing.jl](https://discourse.julialang.org/t/performance-issues-sampling-a-multimomial-logit-slightly-modified-with-turing-jl/90730)

<div class="topic-metadata">

**Author:** [@sarkispa](https://discourse.julialang.org/u/sarkispa)\
**Replies:** 6\
**Last updated:** [November 25, 2022, 3:36pm UTC](https://discourse.julialang.org/t/performance-issues-sampling-a-multimomial-logit-slightly-modified-with-turing-jl/90730 "2022-11-25T15:36:54Z")

</div>

Hi all, I’m essentially trying to sample from a Bayesian multinomial logit with a few complexities: choices have characteristics and choices might not be available in all time periods (no time series here). Choice proba…

---

## [ParetoSmooth.jl psis\_loo crashes with ERROR: The number of lines in \`row\_names\` must match the number of lines in the matrix](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489)

<div class="topic-metadata">

**Author:** [@SebastianCallh](https://discourse.julialang.org/u/SebastianCallh)\
**Replies:** 5\
**Last updated:** [November 24, 2022, 6:34pm UTC](https://discourse.julialang.org/t/paretosmooth-jl-psis-loo-crashes-with-error-the-number-of-lines-in-row-names-must-match-the-number-of-lines-in-the-matrix/90489 "2022-11-24T18:34:53Z")

</div>

Hi! I found an example use of ParetoSmooth.jl psis\_loo here, but when I try to run the example it crashes with \[ Info: No source provided for samples; variables are assumed to be from a Markov Chain. If the samples are…

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

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