File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments