# Probability distribution with complex object support (e.g. \`Tuple{Integer, Matrix}\`)

**URL:** https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964
**Category:** Statistics
**Tags:** distributions
**Created:** [July 20, 2021, 4:13am UTC](https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964 "2021-07-20T04:13:34Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)
#### Post date: [July 20, 2021, 4:13am UTC](https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964/1 "2021-07-20T04:13:34Z")

</div>

The `Distributions.jl` package has great support for continuous and discrete distributions over scalars, vectors, and matrices. Is it meant to support in any way probability distributions in which sampling would return a more complicated object, e.g. a tuple containing integers, symbols, matrices?

---

<div class="post-metadata">

### Author: ![viraltux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/viraltux/32/15236_2.png) [@viraltux](https://discourse.julialang.org/u/viraltux)
#### Post date: [July 23, 2021, 4:21pm UTC](https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964/2 "2021-07-23T16:21:20Z")

</div>

What would stop us from building those complicated objects ourselves with the given distributions? Are you thinking in any specific problem?

---

<div class="post-metadata">

### Author: ![Krastanov](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krastanov/32/6817_2.png) [@Krastanov](https://discourse.julialang.org/u/Krastanov)
#### Post date: [July 23, 2021, 4:29pm UTC](https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964/3 "2021-07-23T16:29:50Z")

</div>

I can build them myself, but I guess I am asking whether there is a “blessed” interface to follow.

I want a distribution which when sampled gives objects like `Tuple{Ket, Real, Category}` where `Category` is basically an enum and `Ket` is a struct containing a matrix and some metadata. It is easy for me to make an object that produces such samples, but I do not know whether other tools and libraries have expectations about interfaces.

---

<div class="post-metadata">

### Author: ![jkbest2](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jkbest2/32/7350_2.png) [@jkbest2](https://discourse.julialang.org/u/jkbest2)
#### Post date: [July 23, 2021, 5:12pm UTC](https://discourse.julialang.org/t/probability-distribution-with-complex-object-support-e-g-tuple-integer-matrix/64964/4 "2021-07-23T17:12:59Z")

</div>

The Distributions.jl documentation has a page on [defining new distributions](https://juliastats.org/Distributions.jl/latest/extends/#Create-a-Distribution). You might have to adapt it a bit, but it will give you an idea of which methods you might want to extend for your distribution.
