zward / Amua

An open source modeling framework
GNU General Public License v3.0
33 stars 11 forks source link

Dirichlet #41

Closed MarkShrime closed 4 years ago

MarkShrime commented 4 years ago

Apologies if this is a simple question.

Amua appears to support a Dirichlet distribution, but the instructions on its use are unclear. Two issues:

  1. The dirichlet requires a vector of alphas, but no syntax I've (yet) tried seems to work to input this vector. All of the following throw errors:

Dir(1,5,4,~) Dir([1,5,4],~) Dir({1,5,4},~) Dir([[1,5,4,]],~) Dir(vector(1,5,4),~)

  1. It's not clear from the help file how to instruct Amua to pick a particular alpha from the vector. If I have three branches from which I want to pick the three standardized probabilities, how do I tell Amua that the first branch should be associated with the first alpha in the vector, second branch with the second alpha, etc.
zward commented 4 years ago

Sorry if this is confusing.
To sample from a Dirichlet distribution you can define a parameter (e.g. called dirichlet) with an expression: Dir([1,5,4],~). The first argument supplies the row vector of alphas [], and the second argument ~ says that you want to sample from the distribution.

To get a value from this parameter (which is a random vector) you reference a particular index of the vector. For example, dirichlet[0] would return the first value, dirichlet[1] would return the second value, etc. Hope this helps!

MarkShrime commented 4 years ago

Thanks, Zach!

zward commented 4 years ago

Added to FAQ and linked to Distributions page