aboutsummaryrefslogtreecommitdiff
path: root/src/lib/math/prob_distr.c
diff options
context:
space:
mode:
authorGeorge Kadianakis <desnacked@riseup.net>2019-03-12 19:04:27 +0200
committerGeorge Kadianakis <desnacked@riseup.net>2019-03-13 17:51:19 +0200
commitfe78ba855a50c1f83e449d63d32e754bc988595a (patch)
tree5f9e4a648b6de7f88be6f9d10c16bb4db898567c /src/lib/math/prob_distr.c
parent8d9f81bc9cdca3022ec3243145bf232fe4f28579 (diff)
downloadtor-fe78ba855a50c1f83e449d63d32e754bc988595a.tar.gz
tor-fe78ba855a50c1f83e449d63d32e754bc988595a.zip
prob_distr: Better document our public API.
Diffstat (limited to 'src/lib/math/prob_distr.c')
-rw-r--r--src/lib/math/prob_distr.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/lib/math/prob_distr.c b/src/lib/math/prob_distr.c
index 2dff9e76e4..bfad06963d 100644
--- a/src/lib/math/prob_distr.c
+++ b/src/lib/math/prob_distr.c
@@ -1316,40 +1316,48 @@ sample_geometric(uint32_t s, double p0, double p)
/** Public API for probability distributions:
*
- * For each probability distribution we define each public functions
- * (sample/cdf/sf/icdf/isf) as part of its dist_ops structure.
+ * These are wrapper functions on top of the various probability distribution
+ * operations using the generic <b>dist</b> structure.
+
+ * These are the functions that should be used by consumers of this API.
*/
+/** Returns the name of the distribution in <b>dist</b>. */
const char *
dist_name(const struct dist *dist)
{
return dist->ops->name;
}
+/* Sample a value from <b>dist</b> and return it. */
double
dist_sample(const struct dist *dist)
{
return dist->ops->sample(dist);
}
+/** Compute the CDF of <b>dist</b> at <b>x</b>. */
double
dist_cdf(const struct dist *dist, double x)
{
return dist->ops->cdf(dist, x);
}
+/** Compute the SF (Survival function) of <b>dist</b> at <b>x</b>. */
double
dist_sf(const struct dist *dist, double x)
{
return dist->ops->sf(dist, x);
}
+/** Compute the iCDF (Inverse CDF) of <b>dist</b> at <b>x</b>. */
double
dist_icdf(const struct dist *dist, double p)
{
return dist->ops->icdf(dist, p);
}
+/** Compute the iSF (Inverse Survival function) of <b>dist</b> at <b>x</b>. */
double
dist_isf(const struct dist *dist, double p)
{
@@ -1419,6 +1427,10 @@ const struct dist_ops uniform_ops = {
.isf = uniform_isf,
};
+/*******************************************************************/
+
+/** Private functions for each probability distribution. */
+
/** Functions for logistic distribution: */
static double