# Status of ABC-SMC samplers in Julia

**URL:** <https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348>\
**Category:** Statistics\
**Tags:** turing, bayesian-inference, monte-carlo, abc, smc\
**Created:** [October 6, 2022, 2:16pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348 "2022-10-06T14:16:10Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Post date:** [October 6, 2022, 2:16pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/1 "2022-10-06T14:16:10Z")

</div>

Hi, I was wondering what is the current status of ABC samplers in Julia.

I have seen that [GpABC.jl](https://github.com/tanhevg/GpABC.jl) has a few options, but I was wondering if there are alternative packages with a special focus on SMC. I do not have something specific in mind, but I am currently exploring the available options - perhaps something like [this](https://github.com/mvihola/AdaptiveToleranceABC_MCMC.jl) but implemented within an active package.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 6, 2022, 2:38pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/2 "2022-10-06T14:38:43Z")

</div>

> **[GitHub - francescoalemanno/KissABC.jl: Pure julia implementation of Multiple...](https://github.com/francescoalemanno/KissABC.jl)**
>
> Pure julia implementation of Multiple Affine Invariant Sampling for efficient Approximate Bayesian Computation - GitHub - francescoalemanno/KissABC.jl: Pure julia implementation of Multiple Affine ...

is probably worth taking a look at

---

<div class="post-metadata">

**Author:** ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Post date:** [October 6, 2022, 3:15pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/3 "2022-10-06T15:15:29Z")

</div>

That’s an option. I wonder whether Turing could also be used for ABC.

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 6, 2022, 3:18pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/4 "2022-10-06T15:18:21Z")

</div>

> [@fipelle](#):
>
> wonder whether Turing could also be used for ABC

ABC is a misnomer IMHO. It’s just bayesian models using summary statistics as observations. So yes. Basically you run your forward model, calculate your summary statistics, and then

```julia
observed_summary ~ SomeKernel(computed_summary,...)

```

Typically Normal kernel.

---

<div class="post-metadata">

**Author:** ![fipelle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fipelle/32/4772_2.png) [@fipelle](https://discourse.julialang.org/u/fipelle)\
**Post date:** [October 6, 2022, 4:12pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/5 "2022-10-06T16:12:02Z")

</div>

In principle and for the simplest cases it is. How would you implement it with Turing? Also, do you know whether SMC is currently supported in that package?

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [October 6, 2022, 4:25pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/6 "2022-10-06T16:25:50Z")

</div>

> [@fipelle](#):
>
> How would you implement it with Turing?

Literally just this

> [@dlakelan](#):
>
> Basically you run your forward model, calculate your summary statistics, and then
> 
> ```julia
> observed_summary ~ SomeKernel(computed_summary,...)
> 
> ```

Yes Turing does SMC of some sort. [https://turing.ml/dev/docs/library/#Turing.Inference.SMC](https://turing.ml/dev/docs/library/#Turing.Inference.SMC)

You basically do

```julia
sample(model,SMC(),...)

```

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [October 7, 2022, 8:53am UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/7 "2022-10-07T08:53:38Z")

</div>

[GitHub - mcreel/SimulatedNeuralMoments.jl: package for Bayesian and classical estimation and inference based on statistics that are filtered through a trained neural net](https://github.com/mcreel/SimulatedNeuralMoments.jl) is a registered package that uses Turing to sample chains, where the likelihood is the asymptotic Gaussian likelihood of the statistics. That’s very much like ABC, using a certain metric to compute loss. In the package, Turing sampling is done using AdvancedMH, because the likelihood is not differentiable, due to the use of simulation.

There are two examples included, one is [SimulatedNeuralMoments.jl/examples/SV at main · mcreel/SimulatedNeuralMoments.jl · GitHub](https://github.com/mcreel/SimulatedNeuralMoments.jl/tree/main/examples/SV), to illustrate.

---

<div class="post-metadata">

**Author:** ![mcreel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcreel/32/30088_2.png) [@mcreel](https://discourse.julialang.org/u/mcreel)\
**Post date:** [October 7, 2022, 9:04am UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/8 "2022-10-07T09:04:23Z")

</div>

For a basic example of ABC using Turing, see [ABC / MSM with Turing.jl](https://discourse.julialang.org/t/abc-msm-with-turing-jl/76189)

---

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [October 7, 2022, 9:23am UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/9 "2022-10-07T09:23:46Z")

</div>

I’ve used KissABC.jl successfully in the past.

---

<div class="post-metadata">

**Author:** ![jbrea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbrea/32/3879_2.png) [@jbrea](https://discourse.julialang.org/u/jbrea)\
**Post date:** [October 7, 2022, 6:53pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/10 "2022-10-07T18:53:16Z")

</div>

I implemented some ABC-SMC methods a while ago [here](https://juliaapproxinference.github.io/LikelihoodfreeInference.jl/dev/reference/), but I never found the time to clean it up further and make better use of the ecosystem (e.g. Turing).

---

<div class="post-metadata">

**Author:** ![mlanghinrichs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mlanghinrichs/32/50371_2.png) [@mlanghinrichs](https://discourse.julialang.org/u/mlanghinrichs)\
**Post date:** [October 6, 2023, 4:36pm UTC](https://discourse.julialang.org/t/status-of-abc-smc-samplers-in-julia/88348/11 "2023-10-06T16:36:51Z")

</div>

A bit shameless self-promotion, but there is also [ABCdeZ.jl](https://github.com/mauricelanghinrichs/ABCdeZ.jl) (I’m the author) 😀 Has a SMC method that does the usual things (partially based on KissABC.jl that was mentioned before) + approximation of model evidences for model comparison.
