# Default sampler for mixed continuous/discrete parameters in Turing.jl

**URL:** <https://discourse.julialang.org/t/default-sampler-for-mixed-continuous-discrete-parameters-in-turing-jl/132874>\
**Category:** Probabilistic Programming\
**Created:** [October 4, 2025, 2:40pm UTC](https://discourse.julialang.org/t/default-sampler-for-mixed-continuous-discrete-parameters-in-turing-jl/132874 "2025-10-04T14:40:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdwfrost](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdwfrost/32/2831_2.png) [@sdwfrost](https://discourse.julialang.org/u/sdwfrost)\
**Post date:** [October 4, 2025, 2:40pm UTC](https://discourse.julialang.org/t/default-sampler-for-mixed-continuous-discrete-parameters-in-turing-jl/132874/1 "2025-10-04T14:40:24Z")

</div>

I’m fitting a Turing.jl model with continuous and discrete variables. Using `MH()` works out of the box. What’s going on under the hood here in terms of samplers and proposals? Any tips on how to tune would be great.

My model snippet:

```Julia
@model function sir_particle_mcmc_fixed_q(P)
    # Priors for the parameters we want to estimate
    β ~ Uniform(0.25, 0.75)
    I₀ ~ DiscreteUniform(5, 50)
    
    # Create parameter tuple with current MCMC values
    current_params = merge(P.params, (β=β, I₀=I₀))

    # Compute particle filter likelihood
    pf_result = pfilter(P, Np=1000, params=current_params) # Reduced particles for speed
    
    # Add the log-likelihood to the model
    Turing.@addlogprob! pf_result.logLik
    
    return nothing
end;

```

---

<div class="post-metadata">

**Author:** ![penelopeysm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/penelopeysm/32/213172_2.png) [@penelopeysm](https://discourse.julialang.org/u/penelopeysm)\
**Post date:** [October 7, 2025, 1:39pm UTC](https://discourse.julialang.org/t/default-sampler-for-mixed-continuous-discrete-parameters-in-turing-jl/132874/2 "2025-10-07T13:39:42Z")

</div>

Hello! I’m not super duper familiar with the MH code, but my understanding is that `MH()` alone generates proposals by sampling from the prior. If you want random-walk or other kinds of proposals it has to be specified in the constructor. The documentation explains this a little bit: [Inference · Turing](https://turinglang.org/Turing.jl/stable/api/Inference/#Turing.Inference.MH)

---

<div class="post-metadata">

**Author:** ![Red-Portal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/red-portal/32/9102_2.png) [@Red-Portal](https://discourse.julialang.org/u/Red-Portal)\
**Post date:** [October 15, 2025, 7:46am UTC](https://discourse.julialang.org/t/default-sampler-for-mixed-continuous-discrete-parameters-in-turing-jl/132874/3 "2025-10-15T07:46:13Z")

</div>

Consider using [SliceSampling](https://github.com/TuringLang/SliceSampling.jl) instead of `MH`. It should work much better.
