# Sample a joint probability matrix from a Dirichlet

Hi, I would like to generate samples from a Dirichlet distribution defined on the nxm probability simplex, i.e. each sample is a nxm matrix whose rows and columns sum to given probability densities (marginals). The only thing I can generate so far using Pyro Dirichlet distribution is a bi-stochastic matrix, for example using: ideal_design = Dirichlet(torch.tensor(0.25 * torch.ones(1, 2, 2))).to_event(1)
Any input on that is appreciated.

can you be more specific? if you want a matrix that doesn’t consistent of independent dirichlet draws for each row (or column) you presumably need a different distribution from dirichlet

Thank you Martin. I would like to sample from the generalised Dirichlet over the probabilty simplex of matrices. Starting from a base distribution on R^{n \times m}, I would like to sample matrices where the sum of rows and columns yield the marginal distributions and the sum of all entries yields 1.

if “generalized dirichlet” refers to a specific distribution known in the literature can you please provide a reference?

afaik no such distribution is implemented in pytorch/pyro/numpyro/tfp so you would probably need to implement such a distribution yourself or find an alternative solution that uses implemented distributions

Thank you, Martin, so is the limitation right now related to the definition of Constraint = Simplex ? If I change this bit, can I generalise the code to my case? Otherwise, what kind of distribution already implemented in Pyro do you suggest for my use case?

i don’t have any suggestions because i don’t understand your use case.

pyro distributions are listed here.

but yes presumably you need something like a DoublyStochasticMatrix constraint and an appropriate distribution defined on that space