summaryrefslogtreecommitdiff
path: root/gi/pyp-topics/src/gammadist.h
diff options
context:
space:
mode:
authorphilblunsom@gmail.com <philblunsom@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-22 20:34:00 +0000
committerphilblunsom@gmail.com <philblunsom@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-06-22 20:34:00 +0000
commitefe0d24fa7dbca47825638a52f51977456153bd0 (patch)
tree77c1d68ae29e423e1baaca6565a2455ec481955c /gi/pyp-topics/src/gammadist.h
parent42e1e2cb20c8f31d9a27bf0be5fe0846f3dde413 (diff)
Initial ci of gi dir
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@5 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'gi/pyp-topics/src/gammadist.h')
-rw-r--r--gi/pyp-topics/src/gammadist.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/gi/pyp-topics/src/gammadist.h b/gi/pyp-topics/src/gammadist.h
new file mode 100644
index 00000000..b6ad6c40
--- /dev/null
+++ b/gi/pyp-topics/src/gammadist.h
@@ -0,0 +1,72 @@
+/* gammadist.h -- computes probability of samples under / produces samples from a Gamma distribution
+ *
+ * Mark Johnson, 22nd March 2008
+ *
+ * gammavariate() was translated from random.py in Python library
+ *
+ * The Gamma distribution is:
+ *
+ * Gamma(x | alpha, beta) = pow(x/beta, alpha-1) * exp(-x/beta) / (gamma(alpha)*beta)
+ *
+ * shape parameter alpha > 0 (also called c), scale parameter beta > 0 (also called s);
+ * mean is alpha*beta, variance is alpha*beta**2
+ *
+ * Note that many parameterizations of the Gamma function are in terms of an _inverse_
+ * scale parameter beta, which is the inverse of the beta given here.
+ */
+
+#ifndef GAMMADIST_H
+#define GAMMADIST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+ /* gammadist() returns the probability density of x under a Gamma(alpha,beta)
+ * distribution
+ */
+
+ long double gammadist(long double x, long double alpha, long double beta);
+
+ /* lgammadist() returns the log probability density of x under a Gamma(alpha,beta)
+ * distribution
+ */
+
+ long double lgammadist(long double x, long double alpha, long double beta);
+
+ /* gammavariate() generates samples from a Gamma distribution
+ * conditioned on the parameters alpha and beta.
+ *
+ * alpha > 0, beta > 0, mean is alpha*beta, variance is alpha*beta**2
+ *
+ * Warning: a few older sources define the gamma distribution in terms
+ * of alpha > -1.0
+ */
+
+ long double gammavariate(long double alpha, long double beta);
+
+ /* betadist() returns the probability density of x under a Beta(alpha,beta)
+ * distribution.
+ */
+
+ long double betadist(long double x, long double alpha, long double beta);
+
+ /* lbetadist() returns the log probability density of x under a Beta(alpha,beta)
+ * distribution.
+ */
+
+ long double lbetadist(long double x, long double alpha, long double beta);
+
+ /* betavariate() generates a sample from a Beta distribution with
+ * parameters alpha and beta.
+ *
+ * 0 < alpha < 1, 0 < beta < 1, mean is alpha/(alpha+beta)
+ */
+
+ long double betavariate(long double alpha, long double beta);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* GAMMADIST_H */