9.6 Low-Level Distribution Functions

► |  | Math Library

1 | Constants and Elementary Functions
2 | Flonums
3 | Special Functions
4 | Number Theory
5 | Arbitrary-Precision Floating-Point Numbers (Bigfloats)
6 | Arrays
7 | Matrices and Linear Algebra
8 | Statistics Functions
9 | Probability Distributions
10 | Stuff That Doesn’t Belong Anywhere Else

▼ | 9 | Probability Distributions

9.1 | Distribution Objects
9.2 | Distribution Types and Operations
9.3 | Finite Distribution Families
9.4 | Integer Distribution Families
9.5 | Real Distribution Families
9.6 | Low-Level Distribution Functions

► | 9.6 | Low-Level Distribution Functions

9.6.1 | Integer Distribution Functions
9.6.2 | Real Distribution Functions

On this page:

9.6.1 Integer Distribution Functions
flbernoulli-pdf
flbernoulli-cdf
flbernoulli-inv-cdf
flbernoulli-sample
flbinomial-pdf
flbinomial-cdf
flbinomial-inv-cdf
flbinomial-sample
flgeometric-pdf
flgeometric-cdf
flgeometric-inv-cdf
flgeometric-sample
flpoisson-pdf
flpoisson-cdf
flpoisson-inv-cdf
flpoisson-sample
flpoisson-median
9.6.2 Real Distribution Functions
flbeta-pdf
flbeta-cdf
flbeta-inv-cdf
flbeta-sample
flcauchy-pdf
flcauchy-cdf
flcauchy-inv-cdf
flcauchy-sample
fldelta-pdf
fldelta-cdf
fldelta-inv-cdf
flexponential-pdf
flexponential-cdf
flexponential-inv-cdf
flexponential-sample
flgamma-pdf
flgamma-cdf
flgamma-inv-cdf
flgamma-sample
fllogistic-pdf
fllogistic-cdf
fllogistic-inv-cdf
fllogistic-sample
flnormal-pdf
flnormal-cdf
flnormal-inv-cdf
flnormal-sample
fltriangle-pdf
fltriangle-cdf
fltriangle-inv-cdf
fltriangle-sample
fluniform-pdf
fluniform-cdf
fluniform-inv-cdf
fluniform-sample

Racket
top contents ← prev up next →

### 9.6 Low-Level Distribution Functions🔗ℹ

The following functions are provided for users who need lower overhead than that of distribution objects, such as untyped Racket users (currently), and library writers who are implementing their own distribution abstractions.

Because applying these functions is meant to be fast, none of them have optional arguments. In particular, the boolean flags log? and 1-p? are always required.

Every low-level function’s argument list begins with the distribution family parameters. In the case of pdfs and cdfs, these arguments are followed by a domain value and boolean flags. In the case of inverse cdfs, they are followed by a probability argument and boolean flags. For sampling procedures, the distribution family parameters are followed by the requested number of random samples.

Generally, prob is a probability parameter, k is an integer domain value, x is a real domain value, p is the probability argument to an inverse cdf, and n is the number of random samples.

#### 9.6.1 Integer Distribution Functions🔗ℹ

> procedure (flbernoulli-pdf prob k log?) → Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> procedure (flbernoulli-cdf prob k log? 1-p?) → Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbernoulli-inv-cdf prob p log? 1-p?) → Flonum
> prob : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbernoulli-sample prob n) → FlVector
> prob : Flonum
> n : Integer

Low-level flonum functions used to implement bernoulli-dist.

> procedure (flbinomial-pdf count prob k log?) → Flonum
> count : Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> procedure (flbinomial-cdf count prob k log? 1-p?) → Flonum
> count : Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbinomial-inv-cdf count prob p log? 1-p?) → Flonum
> count : Flonum
> prob : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbinomial-sample count prob n) → FlVector
> count : Flonum
> prob : Flonum
> n : Integer

Low-level flonum functions used to implement binomial-dist.

> procedure (flgeometric-pdf prob k log?) → Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> procedure (flgeometric-cdf prob k log? 1-p?) → Flonum
> prob : Flonum
> k : Flonum
> log? : Any
> 1-p? : Any
> procedure (flgeometric-inv-cdf prob p log? 1-p?) → Flonum
> prob : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flgeometric-sample prob n) → FlVector
> prob : Flonum
> n : Integer

Low-level flonum functions used to implement geometric-dist.

> procedure (flpoisson-pdf mean k log?) → Flonum
> mean : Flonum
> k : Flonum
> log? : Any
> procedure (flpoisson-cdf mean k log? 1-p?) → Flonum
> mean : Flonum
> k : Flonum
> log? : Any
> 1-p? : Any
> procedure (flpoisson-inv-cdf mean p log? 1-p?) → Flonum
> mean : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flpoisson-sample mean n) → FlVector
> mean : Flonum
> n : Integer
> procedure (flpoisson-median mean) → Flonum
> mean : Flonum

Low-level flonum functions used to implement poisson-dist.

(flpoisson-median mean) runs faster than (flpoisson-inv-cdf mean 0.5 #f #f), significantly so when mean is large.

#### 9.6.2 Real Distribution Functions🔗ℹ

> procedure (flbeta-pdf alpha beta x log?) → Flonum
> alpha : Flonum
> beta : Flonum
> x : Flonum
> log? : Any
> procedure (flbeta-cdf alpha beta x log? 1-p?) → Flonum
> alpha : Flonum
> beta : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbeta-inv-cdf alpha beta p log? 1-p?) → Flonum
> alpha : Flonum
> beta : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flbeta-sample alpha beta n) → FlVector
> alpha : Flonum
> beta : Flonum
> n : Integer

Low-level flonum functions used to implement beta-dist.

> procedure (flcauchy-pdf mode scale x log?) → Flonum
> mode : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> procedure (flcauchy-cdf mode scale x log? 1-p?) → Flonum
> mode : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (flcauchy-inv-cdf mode scale p log? 1-p?) → Flonum
> mode : Flonum
> scale : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flcauchy-sample mode scale n) → FlVector
> mode : Flonum
> scale : Flonum
> n : Integer

Low-level flonum functions used to implement cauchy-dist.

> procedure (fldelta-pdf mean x log?) → Flonum
> mean : Flonum
> x : Flonum
> log? : Any
> procedure (fldelta-cdf mean x log? 1-p?) → Flonum
> mean : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (fldelta-inv-cdf mean p log? 1-p?) → Flonum
> mean : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any

Low-level flonum functions used to implement delta-dist.

To get delta-distributed random samples, use (make-flvector n mean).

> procedure (flexponential-pdf mean x log?) → Flonum
> mean : Flonum
> x : Flonum
> log? : Any
> procedure (flexponential-cdf mean x log? 1-p?) → Flonum
> mean : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (flexponential-inv-cdf mean p log? 1-p?) → Flonum
> mean : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flexponential-sample mean n) → FlVector
> mean : Flonum
> n : Integer

Low-level flonum functions used to implement exponential-dist.

> procedure (flgamma-pdf shape scale x log?) → Flonum
> shape : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> procedure (flgamma-cdf shape scale x log? 1-p?) → Flonum
> shape : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (flgamma-inv-cdf shape scale p log? 1-p?) → Flonum
> shape : Flonum
> scale : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flgamma-sample shape scale n) → FlVector
> shape : Flonum
> scale : Flonum
> n : Integer

Low-level flonum functions used to implement gamma-dist.

> procedure (fllogistic-pdf mean scale x log?) → Flonum
> mean : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> procedure (fllogistic-cdf mean scale x log? 1-p?) → Flonum
> mean : Flonum
> scale : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (fllogistic-inv-cdf mean scale p log? 1-p?) → Flonum
> mean : Flonum
> scale : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (fllogistic-sample mean scale n) → FlVector
> mean : Flonum
> scale : Flonum
> n : Integer

Low-level flonum functions used to implement logistic-dist.

> procedure (flnormal-pdf mean stddev x log?) → Flonum
> mean : Flonum
> stddev : Flonum
> x : Flonum
> log? : Any
> procedure (flnormal-cdf mean stddev x log? 1-p?) → Flonum
> mean : Flonum
> stddev : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (flnormal-inv-cdf mean stddev p log? 1-p?) → Flonum
> mean : Flonum
> stddev : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (flnormal-sample mean stddev n) → FlVector
> mean : Flonum
> stddev : Flonum
> n : Integer

Low-level flonum functions used to implement normal-dist.

> procedure (fltriangle-pdf min max mode x log?) → Flonum
> min : Flonum
> max : Flonum
> mode : Flonum
> x : Flonum
> log? : Any
> procedure (fltriangle-cdf min max mode x log? 1-p?) → Flonum
> min : Flonum
> max : Flonum
> mode : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (fltriangle-inv-cdf min max mode p log? 1-p?) → Flonum
> min : Flonum
> max : Flonum
> mode : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (fltriangle-sample min max mode n) → FlVector
> min : Flonum
> max : Flonum
> mode : Flonum
> n : Integer

Low-level flonum functions used to implement triangle-dist.

> procedure (fluniform-pdf min max x log?) → Flonum
> min : Flonum
> max : Flonum
> x : Flonum
> log? : Any
> procedure (fluniform-cdf min max x log? 1-p?) → Flonum
> min : Flonum
> max : Flonum
> x : Flonum
> log? : Any
> 1-p? : Any
> procedure (fluniform-inv-cdf min max p log? 1-p?) → Flonum
> min : Flonum
> max : Flonum
> p : Flonum
> log? : Any
> 1-p? : Any
> procedure (fluniform-sample min max n) → FlVector
> min : Flonum
> max : Flonum
> n : Integer

Low-level flonum functions used to implement uniform-dist.
top contents ← prev up next →