JWS C Library
C language utility library
|
Definitions for univariate probability mass functions. More...
#include <jwsc/config.h>
#include <stdlib.h>
#include <math.h>
#include <assert.h>
#include <inttypes.h>
#include "jwsc/base/limits.h"
#include "jwsc/prob/pdf.h"
#include "jwsc/prob/pmf.h"
Go to the source code of this file.
Defines | |
#define | INV_E_SINGLE 0.3678794411714423f |
Single precision inverse of the number e. | |
#define | INV_E_DOUBLE 0.36787944117144232159552377016146 |
Double precision inverse of the number e. | |
#define | ALMOST_ONE_SINGLE 0.9999999999999999 |
Single precision value almost equal to one. | |
#define | ALMOST_ONE_DOUBLE 0.99999999999999999999999999999999 |
Double precision value almost equal to one. | |
Functions | |
poission_pmf | |
Computes the Poission pmf at a point. | |
float | poisson_pmf_f (float lambda, uint32_t n) |
Computes the double precision Poisson pmf at a point. | |
double | poisson_pmf_d (double lambda, uint32_t n) |
Computes the double precision Poisson pmf at a point. | |
sample_poisson_pmf | |
Draws a random sample from the Poisson pmf. | |
uint32_t | sample_poisson_pmf_f (float lambda, uint32_t a, uint32_t b) |
Draws a single precision random sample from the Poisson pmf. | |
uint32_t | sample_poisson_pmf_d (double lambda, uint32_t a, uint32_t b) |
Draws a double precision random sample from the Poisson pmf. | |
bernoulli_pmf | |
Computes the Bernoulli pmf at a point. | |
float | bernoulli_pmf_f (float p, uint32_t n) |
Computes the single precision Bernoulli pmf at a point. | |
double | bernoulli_pmf_d (double p, uint32_t n) |
Computes the double precision Bernoulli pmf at a point. | |
sample_bernoulli_pmf | |
Draws a random sample from the Bernoulli pmf. | |
uint8_t | sample_bernoulli_pmf_f (float p) |
Draws a single precision random sample from the Bernoulli pmf. | |
uint8_t | sample_bernoulli_pmf_d (double p) |
Draws a double precision random sample from the Bernoulli pmf. | |
geometric_pmf | |
Computes the Geometric pmf at a point. | |
float | geometric_pmf_f (float p, uint32_t n) |
Computes the single precision Geometric pmf at a point. | |
double | geometric_pmf_d (double p, uint32_t n) |
Computes the double precision Geometric pmf at a point. | |
log_geometric_pmf | |
Computes the log of the Geometric pmf at a point. | |
float | log_geometric_pmf_f (float p, uint32_t n) |
Computes the single precision log Geometric pmf at a point. | |
double | log_geometric_pmf_d (double p, uint32_t n) |
Computes the double precision log Geometric pmf at a point. | |
sample_geometric_pmf | |
Draws a random sample from the Geometric pmf. | |
uint32_t | sample_geometric_pmf_f (float p) |
Draws a single precision random sample from the Geometric pmf. | |
uint32_t | sample_geometric_pmf_d (double p) |
Draws a double precision random sample from the Geometric pmf. |
Definitions for univariate probability mass functions.
Definition in file pmf.c.
#define INV_E_SINGLE 0.3678794411714423f |
#define INV_E_DOUBLE 0.36787944117144232159552377016146 |
#define ALMOST_ONE_SINGLE 0.9999999999999999 |
#define ALMOST_ONE_DOUBLE 0.99999999999999999999999999999999 |
float poisson_pmf_f | ( | float | lambda, |
uint32_t | n | ||
) |
Computes the double precision Poisson pmf at a point.
lambda | Mean and variance of the Poisson. |
n | Value to get the probability of. |
double poisson_pmf_d | ( | double | lambda, |
uint32_t | n | ||
) |
Computes the double precision Poisson pmf at a point.
lambda | Mean and variance of the Poisson. |
n | Value to get the probability of. |
uint32_t sample_poisson_pmf_f | ( | float | lambda, |
uint32_t | a, | ||
uint32_t | b | ||
) |
Draws a single precision random sample from the Poisson pmf.
lambda | Mean and variance of the Poisson. |
a | Lower bound of the sampling interval. |
b | Upper bound of the sampling interval. |
uint32_t sample_poisson_pmf_d | ( | double | lambda, |
uint32_t | a, | ||
uint32_t | b | ||
) |
Draws a double precision random sample from the Poisson pmf.
lambda | Mean and variance of the Poisson. |
a | Lower bound of the sampling interval. |
b | Upper bound of the sampling interval. |
float bernoulli_pmf_f | ( | float | p, |
uint32_t | n | ||
) |
Computes the single precision Bernoulli pmf at a point.
p | Probability of success, i.e., n == 1. |
n | Value to get the probability of. Must be either 0 or 1. |
double bernoulli_pmf_d | ( | double | p, |
uint32_t | n | ||
) |
Computes the double precision Bernoulli pmf at a point.
p | Probability of success, i.e., n == 1. |
n | Value to get the probability of. Must be either 0 or 1. |
uint8_t sample_bernoulli_pmf_f | ( | float | p | ) |
Draws a single precision random sample from the Bernoulli pmf.
p | Probability of success. |
uint8_t sample_bernoulli_pmf_d | ( | double | p | ) |
Draws a double precision random sample from the Bernoulli pmf.
p | Probability of success. |
float geometric_pmf_f | ( | float | p, |
uint32_t | n | ||
) |
Computes the single precision Geometric pmf at a point.
p | Probability of success, must be in (0,1). |
n | Number of failures before a success, must be >= 0. |
Computes
(1-p)^n * p
double geometric_pmf_d | ( | double | p, |
uint32_t | n | ||
) |
Computes the double precision Geometric pmf at a point.
p | Probability of success, must be in (0,1). |
n | Number of failures before a success, must be >= 0. |
Computes
(1-p)^n * p
float log_geometric_pmf_f | ( | float | p, |
uint32_t | n | ||
) |
Computes the single precision log Geometric pmf at a point.
p | Probability of success, must be in (0,1). |
n | Number of failures before a success, must be >= 0. |
Computes
log((1-p)^n * p)
double log_geometric_pmf_d | ( | double | p, |
uint32_t | n | ||
) |
Computes the double precision log Geometric pmf at a point.
p | Probability of success, must be in (0,1). |
n | Number of failures before a success, must be >= 0. |
Computes
(1-p)^n * p
uint32_t sample_geometric_pmf_f | ( | float | p | ) |
Draws a single precision random sample from the Geometric pmf.
p | Probability of success, must be in (0,1). |
uint32_t sample_geometric_pmf_d | ( | double | p | ) |
Draws a double precision random sample from the Geometric pmf.
p | Probability of success, must be in (0,1). |