aboutsummaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/misc.c b/src/misc.c
index 605f3ea..d5667e8 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -498,3 +498,11 @@ double std(const double *x, size_t n)
return sqrt(sum/n);
}
+
+double gamma_pdf(double x, double k, double theta)
+{
+ /* Returns the PDF for the gamma distribution.
+ *
+ * See https://en.wikipedia.org/wiki/Gamma_distribution. */
+ return pow(x,k-1)*exp(-x/theta)/(gsl_sf_gamma(k)*pow(theta,k));
+}