HyPhy message board
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl
Methodology Questions >> How to >> Sampling from a Beta(a,b) distribution
http://www.hyphy.org/cgi-bin/hyphy_forums/YaBB.pl?num=1290804081

Message started by SamW on Nov 26th, 2010 at 12:41pm

Title: Sampling from a Beta(a,b) distribution
Post by SamW on Nov 26th, 2010 at 12:41pm
Can anyone help with how to draw random numbers from a Beta(a,b) distribution?  

I'm programming a Dirichlet Process Prior for rate categories but do not know of a built-in HyPhy function that draws from this distribution.

Does one already exist?  If so, can someone point me to source code or instructions on how to implement?

Any help will be much appreciated.  Thank you!

Title: Re: Sampling from a Beta(a,b) distribution
Post by Sergei on Dec 10th, 2010 at 3:12pm
Hi Sam,

Sorry took me a while to answer. Look inside TemplateBatchFiles/Utility/ProbabilityDistributions.bf
It has a sampleFromBeta (p,q) function.

Use example:

[code]
LoadFunctionLibrary ("ProbabilityDistributions");

for (k = 0; k < 10; k += 1)
{
    fprintf (stdout, sampleFromBeta (5,5), "\n");
}

[/code]

Sergei

Title: Re: Sampling from a Beta(a,b) distribution
Post by SamW on Dec 10th, 2010 at 4:28pm
Thanks a bunch!  I was wondering where those distros are at.  

Sam

HyPhy message board » Powered by YaBB 2.5.2!
YaBB Forum Software © 2000-2024. All Rights Reserved.