TuringLang / docs

Documentation and tutorials for the Turing language
https://turinglang.org/docs/
MIT License
229 stars 98 forks source link

01_gaussian-mixture-model fails due to surprisingly tight tolerance check. #438

Closed JasonPekos closed 4 months ago

JasonPekos commented 5 months ago

Trying to weave the current GMM tutorial fails with:

ERROR: AssertionError: Difference between estimated mean of μ ([-3.1465091632143567, 0.6286046354218603]) and data-generating μ ([-3.5, 0.5]) unexpectedly large!

Due to this check:

let
    # Verify that the output of the chain is as expected.
    for i in MCMCChains.chains(chains)
        # μ[1] and μ[2] can switch places, so we sort the values first.
        chain = Array(chains[:, ["μ[1]", "μ[2]"], i])
        μ_mean = vec(mean(chain; dims=1))
        @assert isapprox(sort(μ_mean), μ; rtol=0.1) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
    end
end

The notebook only draws 100 samples, and the data (only 60 samples) will also vary from the true mean, so I think this is bound should be loosened.

I am already working on extending tutorial as discussed in the slack, and so I can change this too, if desired.

shravanngoswamii commented 4 months ago

Is this still an issue in the current GMM tutorial, I guess we fixed all issues so this should be closed now!