In Distributions.jl is it possible to create a cartesian product distribution, given two univariate random variables? I want to do this to make a multivariate uniform distribution supported over [0,1]\times[0,1]

# Product of univariate distributions

There’s no tooling for this at the moment, but there are several issues describing it. It’s pretty easy to use the existing distributions code as a template to create a new distribution.

**gragusa**#4

I have a small package implementing this that I use for MC where the product distribution is the prior. BayesianTools.jl. There is no documentation at the moment, but the test directory has the basic use cases.

**nbren12**#5

yes! this seems like exactly what I need. Thanks. I just wanted to make a

multi-dimensional uniform distribution for MC.

-Noah

**gragusa**#6

@nbren12 Since you were interested in this, I put some effort to update the package, include more thorough testing, and add a brief documentation. Let me know if this is useful to you and how can be improved.

**dpsanders**#7

Isn’t sampling from a multi-dimensional uniform distribution just given by

```
n = 3 # dimension
x = rand(n)
```

?

**nbren12**#9

Distributions.jl does more than just sampling. It stores the pdf and other info which are necessary for doing things like Bayesian statistics.

**dpsanders**#11

Right, but everything is very trivial in the particular case of uniform distributions.

Certainly for non-uniform distributions, something more would be useful – maybe it could be refactored out of `BayesianTools.jl`

into a separate package or part of `Distributions.jl`

? cc @gragusa

**johnmyleswhite**#12

We’ve got some issues about this product idea for Distributions. The main difficulty is whether you want to support arrays or tuples. I prefer tuples because you can handle heterogeneous types, but that creates other issues.

**gragusa**#13

Yes I struggle with this myself. I just went for tuples because it seemed more natural and handle heterogeneity (alternatively you could go with generated functions, but it seems overkill to me). I just put this together because I needed it and I am not claiming that this is the best implementation — I just find this useful for the MCMC stuff I do.

@dpsanders happy to factor out whathever it is relevant

**baggepinnen**#14

I am interested in learning if there has been any progress on product distributions in Distributions.jl or `BayesianTools.ProductDistributions`

l is still the way to go?