Skip to content

Gibbs gives different sampling results with fixed rng #1731

@bvdmitri

Description

@bvdmitri

Hey, thanks for the nice package!

Recently I probably came across a bug in Turing.jl. I run a slightly modified version of HMM demo. I use the following inference function:

function inference_turing(observations; nsamples = 500, seed = 42)
    rng     = MersenneTwister(seed)
    sampler = Turing.Gibbs(Turing.HMC(0.1, 40, :A, :B), Turing.PG(010, :z))
    return Turing.sample(rng, BayesHmm(observations, 3), sampler, nsamples)
end

What I noticed is that results are always different though I fix my rng and seed. If I do

Random.seed!(seed)

in the beginning of inference_turing then results are consistent and are always the same. It makes me feel that Gibbs sampler ignores rng setting. It didn't happen to me before with HMC sampler for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions