Hello,(adsbygoogle = window.adsbygoogle || []).push({});

I am working on a problem in which I first sample two unknown probabilities, p and q, from Beta distributions, and then I want to sample both of them at the same time from a multivariate Beta distribution.

This is the code that I have for sampling p and q individually from Beta distributions (I have already defined a, b, c, d, x, n, and s):

p=betarnd(a+x,b+n-x);

q=betarnd(c+s,d+x+2*(n-x)-s)

Now I'm trying to figure out how to sample p and q jointly from a multivariate Beta distribution.

I know that the Dirichlet distribution is a generalization of the multivariate Beta distribution, and after searching online, I think that I can sample p and q individually from the Dirichlet distribution by doing the following:

alpha_p = [a+x b+n-x];

alpha_q=[c+s d+x+2*(n-x)-s];

d_p=gamrnd(alpha_p, 1);

theta_p=d_p./sum(d_p);

d_q=gamrnd(alpha_q, 1);

theta_q=d_q./sum(d_q);

This results in 2x1 vectors theta_p and theta_q, with the entries in each vector adding up to 1. I'm letting p equal the first entry of theta_p, and q equal the first entry of theta_q.

I'm not sure if this is the right method for the multivariate Beta distribution, but even if it is,

I still don't know how to sample p and q from the Dirichlet distribution at the same time.

Any help would be much appreciated : )

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# MATLAB How to write Matlab code for a multivariate Beta distribution

Loading...

Similar Threads for write Matlab code |
---|

MATLAB MATLAB: forces acting on an object |

MATLAB Matlab histogram |

MATLAB Sovling Bernoulli's differential equation in matlab? |

MATLAB Matlab-like software |

MATLAB Matlab data into bins |

**Physics Forums | Science Articles, Homework Help, Discussion**