/libbeta

Sample from Beta distribution

Primary LanguageCMIT LicenseMIT

libbeta

Sample from the Beta distribution

Quickstart

Build two sample programs:

  • build a histogram of sample counts (10 bins)
  • stream of samples
$ mkdir build
$ cd build
$ cmake ..
$ make

Run the sample programs:

$ ./sample_hist 1.0 2.0
1821 1679 1602 1274 1117 890 756 475 278 108 

$ ./sample_stream 1.0 2.0
0.130430
0.622695
0.473631
...
<Ctrl-C>

Usage

  1. Include the header libbeta.h into your program

  2. Set parameters a and b for the Beta distribution to sample from

  3. Call beta_sample_BA(a, b) to get a sample

Credits

Inspired by James McCaffrey's Blog

References

[1] R. C. H. Cheng, Generating Beta Variates with Nonintegral Shape Parameters, Communications of the ACM, Vol. 21, Issue 4, pp. 317-322, 1978.