# Pick the value from a result

**URL:** <https://discourse.julialang.org/t/pick-the-value-from-a-result/118713>\
**Category:** Probabilistic Programming\
**Tags:** question, indexing, rxinfer\
**Created:** [August 28, 2024, 2:03pm UTC](https://discourse.julialang.org/t/pick-the-value-from-a-result/118713 "2024-08-28T14:03:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen](https://avatars.discourse-cdn.com/v4/letter/s/96bed5/32.png) [@Stephen](https://discourse.julialang.org/u/Stephen)\
**Post date:** [August 28, 2024, 2:03pm UTC](https://discourse.julialang.org/t/pick-the-value-from-a-result/118713/1 "2024-08-28T14:03:12Z")

</div>

Here is a [solution of a Bayesian inference](https://github.com/orgs/ReactiveBayes/discussions/56#discussioncomment-10242361) using RxInfer:

```julia
julia> result
Inference results:
  Posteriors | available for (i_β)

julia> result.posteriors
Dict{Symbol, Vector{Dirichlet{Float64, Vector{Float64}, Float64}}} with 1 entry:
  :i_β => [Dirichlet{Float64, Vector{Float64}, Float64}(alpha=[…

julia> result.posteriors[:i_β][1]
Dirichlet{Float64, Vector{Float64}, Float64}(alpha=[0.01559091258256351, 0.20785569702925843, 1.0099435968993862])

julia> result.posteriors[:i_β][1].alpha
3-element Vector{Float64}:
 0.01559091258256351
 0.20785569702925843
 1.0099435968993862

julia> result.posteriors[:i_β][1].alpha[1]
0.01559091258256351

```

Too tedious to get the value wanted, any convenient method?

---

<div class="post-metadata">

**Author:** ![timn](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timn/32/211595_2.png) [@timn](https://discourse.julialang.org/u/timn)\
**Post date:** [August 29, 2024, 8:36am UTC](https://discourse.julialang.org/t/pick-the-value-from-a-result/118713/2 "2024-08-29T08:36:46Z")

</div>

Not as far as I know.

If the posterior of `i_β` is always a `Dirichlet` (or any other distribution with an `alpha` vector parameter) then you can define a helper function

```julia
function get_alpha(result, index, element)
    return result.posteriors[:i_β][index].alpha[element]
end

```

and call it with `alpha_value = get_alpha(result, 1, 1)`.

RxInfer.jl uses Distributions.jl, so if you want easy access to parameters of distributions like a Dirichlet, you have to open an issue there.
