Macaulay2 » Documentation
Packages » Probability :: Probability
next | previous | forward | backward | up | index | toc

# Probability -- basic probability functions

## Description

This package provides a number of basic probability functions. In particular, for both discrete and continuous probability distributions, there are the following four functions:

- density: probability density (or mass) function
- probability: cumulative distribution function
- quantile: quantile function
- random(ProbabilityDistribution): generate random samples

A variety of common probability distributions are supported.

### Discrete distributions

- binomial
- Poisson
- geometric
- negative binomial
- hypergeometric

### Continuous distributions

- uniform
- exponential
- normal
- gamma
- chi-squared
- Student's t
- F
- beta

You may also define your own probability distributions using discreteProbabilityDistribution and continuousProbabilityDistribution.

## Caveat

As is always the case when working with real numbers in Macaulay2, unexpected results may occur due to the limitations of floating point arithmetic.

### Menu

- ProbabilityDistribution -- probability distribution class

## Author

- Doug Torrance <dtorrance@piedmont.edu>

## Certification

Version 0.3 of this package was accepted for publication in volume 14 of Journal of Software for Algebra and Geometry on 2024-01-23, in the article The Probability package for Macaulay2 (DOI: 10.2140/jsag.2024.14.51). That version can be obtained from the journal.

## Version

This documentation describes version 0.6 of Probability, released November 10, 2025.

## Citation

If you have used this package in your research, please cite it as follows:

    @misc{ProbabilitySource,
      title = {{Probability: basic probability functions. Version~0.6}},
      author = {Doug Torrance},
      howpublished = {A \emph{Macaulay2} package available at
        \url{https://github.com/Macaulay2/M2/tree/stable/M2/Macaulay2/packages}}
    }

    @article{ProbabilityArticle,
      title = {{The Probability package for \emph{Macaulay2}}},
      author = {Doug Torrance},
      journal = {Journal of Software for Algebra and Geometry},
      volume = {14},
      year = {2024},
    }

## Exports

- Types
  - `ContinuousProbabilityDistribution` -- see ProbabilityDistribution -- probability distribution class
  - `DiscreteProbabilityDistribution` -- see ProbabilityDistribution -- probability distribution class
  - ProbabilityDistribution -- probability distribution class
- Functions and commands
  - betaDistribution -- beta distribution
  - `bernoulliDistribution` -- see binomialDistribution -- binomial distribution
  - binomialDistribution -- binomial distribution
  - chiSquaredDistribution -- chi-squared distribution
  - continuousProbabilityDistribution -- construct a continuous probability distribution
  - density -- probability density (or mass) function
  - discreteProbabilityDistribution -- construct a discrete probability distribution
  - exponentialDistribution -- exponential distribution
  - fDistribution -- F-distribution
  - gammaDistribution -- gamma distribution
  - geometricDistribution -- geometric distribution
  - hypergeometricDistribution -- hypergeometric distribution
  - negativeBinomialDistribution -- negative binomial distribution
  - normalDistribution -- normal distribution
  - poissonDistribution -- Poisson distribution
  - probability -- cumulative distribution function
  - quantile -- quantile function
  - tDistribution -- Student's t-distribution
  - uniformDistribution -- continuous uniform distribution
- Methods
  - `betaDistribution(Number,Number)` -- see betaDistribution -- beta distribution
  - `bernoulliDistribution(Number)` -- see binomialDistribution -- binomial distribution
  - `binomialDistribution(ZZ,Number)` -- see binomialDistribution -- binomial distribution
  - `chiSquaredDistribution(Number)` -- see chiSquaredDistribution -- chi-squared distribution
  - `continuousProbabilityDistribution(Function)` -- see continuousProbabilityDistribution -- construct a continuous probability distribution
  - `density(DiscreteProbabilityDistribution,Number)` -- see density -- probability density (or mass) function
  - `density(ProbabilityDistribution,Number)` -- see density -- probability density (or mass) function
  - `discreteProbabilityDistribution(Function)` -- see discreteProbabilityDistribution -- construct a discrete probability distribution
  - `exponentialDistribution(Number)` -- see exponentialDistribution -- exponential distribution
  - `fDistribution(Number,Number)` -- see fDistribution -- F-distribution
  - `gammaDistribution(Number,Number)` -- see gammaDistribution -- gamma distribution
  - `geometricDistribution(Number)` -- see geometricDistribution -- geometric distribution
  - `hypergeometricDistribution(ZZ,ZZ,ZZ)` -- see hypergeometricDistribution -- hypergeometric distribution
  - `negativeBinomialDistribution(Number,Number)` -- see negativeBinomialDistribution -- negative binomial distribution
  - `normalDistribution(Number,Number)` -- see normalDistribution -- normal distribution
  - `poissonDistribution(Number)` -- see poissonDistribution -- Poisson distribution
  - `probability(DiscreteProbabilityDistribution,Number)` -- see probability -- cumulative distribution function
  - `probability(ProbabilityDistribution,Number)` -- see probability -- cumulative distribution function
  - `net(ProbabilityDistribution)` -- see ProbabilityDistribution -- probability distribution class
  - `quantile(DiscreteProbabilityDistribution,Number)` -- see quantile -- quantile function
  - `quantile(ProbabilityDistribution,Number)` -- see quantile -- quantile function
  - random(ProbabilityDistribution) -- randomly generate samples from probability distribution
  - `tDistribution(Number)` -- see tDistribution -- Student's t-distribution
  - `uniformDistribution(Number,Number)` -- see uniformDistribution -- continuous uniform distribution
- Symbols
  - DensityFunction -- probability density function
  - DistributionFunction -- cumulative distribution function
  - LowerTail -- whether to computer lower tail probabilities
  - QuantileFunction -- quantile function
  - RandomGeneration -- random generation function
  - Support -- support for probability distribution

## For the programmer

The object Probability is a package, defined in Probability.m2.

The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Probability.m2:474:0.