Skip to content

stochastical/distro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

distro

Defines common probability distributions and their associated functions (pdf, cdf, mean, variance, etc.) in pure Typst.

Warning

This library is still in early development, please use with caution. Typst is not designed for robust statistical use, and built-in functions like calc.binom overflow quickly.

Some of the numerical computations are derived from the Rust statrs crate.

Installation

This package is currently not packaged for Typst Universe, but will be once it stabilises a bit more. In the meantime, you can just grab the code directly from here.

Usage

#import calc: sqrt, pi
#import "@preview:distro": normal

#{
  let Z = normal.new(mean: 0, std: 1)
  assert((Z.mean, Z.variance) == (0, 1))
  assert(normal.pdf(Z)(0) == 1 / sqrt(2 * pi))
}

Please also see the examples folder for more applications.

Since Typst doesn't (currently) support custom objects and methods, you must pass the instance of the distribution variable into the associated pdf or cdf function. The new function acts as a constructor, validating the paramaters, and returning a dictionary that stores the mean and variance.

Discrete distributions

Continuous distributions

About

A pure Typst statistics library for common probability distributions.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages