Skip to content

Commit f26fd7e

Browse files
committed
Rel 4.4.5 - Disable particles(mcmcchains)
1 parent 1a4ae9a commit f26fd7e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

src/particles_mcmcchains.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
# This is copied and shortened from Turing2MonteCarloChains.jl!
3+
4+
# Doesn't work reliably!
5+
6+
function MonteCarloMeasurements.Particles(t::NTuple{N, <:AxisArrays.AxisArray}; start=0) where N
7+
[adapted_particles(t[i].data[start+1:end,:]) for i in 1:N]
8+
end
9+
10+
function MonteCarloMeasurements.Particles(a::AxisArrays.AxisArray; start=0)
11+
adapted_particles(a.data[start+1:end,:])
12+
end
13+
14+
"""
15+
Particles(chain::Chains; start=0)
16+
17+
Return a named tuple of particles or vector of particles where the keys
18+
are the symbols in the Turing model that produced the chain. `start>0` can
19+
be given to discard a number of samples from the beginning of the chain.
20+
21+
```
22+
"""
23+
function MonteCarloMeasurements.Particles(chain::Chains; start=0)
24+
p = get_params(chain)
25+
(;collect((k => Particles(getfield(p,k); start=start) for k in keys(p)))...)
26+
end
27+
28+
function adapted_particles(v)
29+
T = float(typeof(v[1]))
30+
Particles(vec(T.(v)))
31+
end

0 commit comments

Comments
 (0)