Closed gipert closed 1 month ago
Is this a bug? The samples seem sane...
using StatsBase using Statistics using Distributions using BAT using DensityInterface using IntervalSets counts = (pass = [3, 102, 3], fail = [3, 4, 1]) likelihood = let data = counts function logpdf_poisson(ν, μ) return logpdf(Poisson(μ + eps(μ)), ν) end logfuncdensity(function (parameters) p = parameters return ( logpdf_poisson(counts.pass[1] + counts.pass[3], 2 * p.μb * p.ϵb) + logpdf_poisson(counts.fail[1] + counts.fail[3], 2 * p.μb * (1 - p.ϵb)) + logpdf_poisson(counts.pass[2], p.μb * p.ϵb + p.μs * p.ϵs) + logpdf_poisson(counts.fail[2], p.μb + p.μs - p.μb * p.ϵb - p.μs * p.ϵs) ) end) end prior = distprod( μb = 0..200, μs = 0..200, ϵb = 0..(1-eps()), ϵs = 0..(1-eps()), ) posterior = PosteriorMeasure(likelihood, prior) samples = bat_sample(posterior, MCMCSampling(mcalg = MetropolisHastings(), nsteps = 10^5, nchains = 4)).result bat_report(samples)
Output:
Tuple field type cannot be Union{} Stacktrace: [1] #s1#1 @ ~/.julia/packages/TypedTables/ItVth/src/TypedTables.jl:22 [inlined] [2] var"#s1#1"(names::Any, T::Any, ::Any, a::Any) @ TypedTables ./none:0 [3] (::Core.GeneratedFunctionStub)(::UInt64, ::LineNumberNode, ::Any, ::Vararg{Any}) @ Core ./boot.jl:602 [4] _table(nt::@NamedTuple{parameter::Vector{Symbol}, value::Vector{Union{}}}) @ TypedTables ~/.julia/packages/TypedTables/ItVth/src/Table.jl:31 [5] Table @ ~/.julia/packages/TypedTables/ItVth/src/Table.jl:24 [inlined] [6] fixed_parameter_table(smplv::StructArrays.StructVector{DensitySample{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, Float64, Int64, BAT.MCMCSampleID, Nothing}, @NamedTuple{v::ValueShapes.ShapedAsNTArray{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, 1, ArraysOfArrays.ArrayOfSimilarArrays{Float64, 1, 1, 2, ElasticArrays.ElasticMatrix{Float64, Vector{Float64}}}, ValueShapes.NamedTupleShape{(:μb, :μs, :ϵb, :ϵs), NTuple{4, ValueShapes.ValueAccessor{ValueShapes.ScalarShape{Real}}}, NamedTuple}}, logd::Vector{Float64}, weight::Vector{Int64}, info::StructArrays.StructVector{BAT.MCMCSampleID, @NamedTuple{chainid::Vector{Int32}, chaincycle::Vector{Int32}, stepno::Vector{Int64}, sampletype::Vector{Int64}}, Int64}, aux::Vector{Nothing}}, Int64}) @ BAT ~/.julia/packages/BAT/pYfQ6/src/statistics/report.jl:63 [7] bat_report!(md::Markdown.MD, smplv::StructArrays.StructVector{DensitySample{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, Float64, Int64, BAT.MCMCSampleID, Nothing}, @NamedTuple{v::ValueShapes.ShapedAsNTArray{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, 1, ArraysOfArrays.ArrayOfSimilarArrays{Float64, 1, 1, 2, ElasticArrays.ElasticMatrix{Float64, Vector{Float64}}}, ValueShapes.NamedTupleShape{(:μb, :μs, :ϵb, :ϵs), NTuple{4, ValueShapes.ValueAccessor{ValueShapes.ScalarShape{Real}}}, NamedTuple}}, logd::Vector{Float64}, weight::Vector{Int64}, info::StructArrays.StructVector{BAT.MCMCSampleID, @NamedTuple{chainid::Vector{Int32}, chaincycle::Vector{Int32}, stepno::Vector{Int64}, sampletype::Vector{Int64}}, Int64}, aux::Vector{Nothing}}, Int64}) @ BAT ~/.julia/packages/BAT/pYfQ6/src/statistics/report.jl:95 [8] bat_report(obj::StructArrays.StructVector{DensitySample{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, Float64, Int64, BAT.MCMCSampleID, Nothing}, @NamedTuple{v::ValueShapes.ShapedAsNTArray{@NamedTuple{μb::Float64, μs::Float64, ϵb::Float64, ϵs::Float64}, 1, ArraysOfArrays.ArrayOfSimilarArrays{Float64, 1, 1, 2, ElasticArrays.ElasticMatrix{Float64, Vector{Float64}}}, ValueShapes.NamedTupleShape{(:μb, :μs, :ϵb, :ϵs), NTuple{4, ValueShapes.ValueAccessor{ValueShapes.ScalarShape{Real}}}, NamedTuple}}, logd::Vector{Float64}, weight::Vector{Int64}, info::StructArrays.StructVector{BAT.MCMCSampleID, @NamedTuple{chainid::Vector{Int32}, chaincycle::Vector{Int32}, stepno::Vector{Int64}, sampletype::Vector{Int64}}, Int64}, aux::Vector{Nothing}}, Int64}) @ BAT ~/.julia/packages/BAT/pYfQ6/src/statistics/report.jl:17 [9] top-level scope @ In[39]:1
That looks like a bug, TypedTables.Table(samples.v) works fine, for example. I'll look into it.
TypedTables.Table(samples.v)
Should be fixed now.
Is this a bug? The samples seem sane...
Output: