A collection of statistical and mathematical methods also available as Excel functions.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Build Status Build status Coverage Status Code Health

About mathpy

mathpy is a collection of mathematical and statistical functions encompassing several different fields such as linear algebra, numerical analysis, and number theory. The package is intended to work with other popular scientific computing packages such as numpy and scipy. Most functions in The mathpy package are also available as Excel UDFs for users who prefer working in Excel. The mathpy project is primarily a personal project intended to develop a deeper understanding of the mathematics and algorithmic implementations of various mathematical topics.


The documentation of the mathpy package is available here:


The documentation for importing the mathpy functions to use in Excel as UDFs is found here:



Mathpy is easily installed through pip and is the most recommended approach.

pip install mathpy

The package should also be able to install from Github with the following command:

pip install git+https://github.com/aschleg/mathpy.git

The Github repository can also be cloned and installed with the included setup.py script.

git clone https://github.com/aschleg/mathpy.git
python setup.py install

Installation Requirements

Recommended to install the Anaconda distribution for your preferred version of Python.

  • Python 2.7 or 3+

    • Please note, with the official discontinuation of Python 2.7 support in the near future, mathpy will no longer attempt to remain 2.7 compatible. Though most of the functions should still work with Python 2.7, support will not continue.
  • Compatible with Windows, Mac and Linux OS.

    • Excel UDFs are currently available in Windows only.

Available Methods

  • Combinatorics

    • Binomial Coefficient
  • Linear Algebra

    • Matrix Decomposition
    • Vector and Matrix Norms
    • Matrix Tests
  • Numerical Analysis

    • Numerical Differentiation
    • Numerical Integration
    • Polynomial Evaluation
    • Polynomial Interpolation
    • Roots of Polynomials
  • Number Theory

    • Integer Factorization
    • Greatest Common Divisor
    • Prime Numbers
    • Integer Sequences
  • Probability Distributions

    • Continous Distributions
      • Uniform
    • Discrete Distributions
      • Bernoulli
      • Binomial
  • Random Sampling and PRNGs (Pseudorandom Number Generators)

    • Continuous Distributions
      • Uniform
    • Discrete Distributions
      • Bernoulli
      • Binomial
    • Pseudorandom Number Generators
      • Linear Congruential Generator
      • Combined Linear Congruential Generators
      • Lehmer Random Number Generator (Multiplicative Congruential Generator)
  • Set Theory

    • Extensions to Python set class
    • Multiple union and intersection operations
    • Cartesian products
    • Relative Complements of multiple sets
  • Special Functions

    • Factorials
  • Statistics

    • Factor Analysis
    • ANOVA and MANOVA
    • Hypothesis Testing
    • Covariance and Correlation Matrices
    • Variance
    • Simulating Correlation Matrices