Stand-alone code for numerical computing

Sometimes you need a little code to do some scientific computing and you don’t want to take on a dependence to a huge and possibly unfamiliar library. This page is an index to code snippets in multiple languages that solve that problem.

The software listed here has been designed to minimize dependencies, minimize complexity, and maximize transparency. That sometimes means sacrificing efficiency.

All code here is under BSD license. Do whatever you want with it. Use at your own risk.

Feedback is always appreciated.

 

Special functions

Error function: C++, Python, C#, Haskell

Phi (standard normal CDF): C++, Python, C#Haskell

Phi inverse: C++, Python, C#, Haskell

Gamma: C++, C#

Log Gamma: C++, C#

log(1 + x) for small x: C++, Python, C# (why?)

exp(x) – 1 for small x: C++, Python, C# (why?)

log( n! ): C++, C#

 

Random number generation

Chi-square: C++

Exponential: C++, Python

Gamma: C++, Python

Inverse gamma: C++

Laplace: C++

Log normal: C++

Normal: C++, Python

Poisson: C++

Student-t: C++, Python

Uniform: C++

Weibull: C++

C++ TR1 has code for generating random samples from normal, exponential, gamma, and Poisson distributions directly. Random number generation using C++ TR1 explains how to use this built-in functionality and now to bootstrap the built-in functions to generate samples from Cauchy, Student-t, Snedecor-F, and Weibull distributions.