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 in the public domain. Do whatever you want with it, no strings attached. Use at your own risk.

I'm just getting started with this project. I intend to add functions and programming languages over time. Feedback is always appreciated.

 

Special functions

Error function: C++, Python, C#

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

Phi inverse: C++, Python, C#

Gamma: C++, C#

Log Gamma: C++, C#

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

exp(x) - 1 for small x: C++, Python, C#

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

 

Random number generation

Beta: C++, Python, C#

Cauchy: C++, Python, C#

Chi-square: C++, C#

Exponential: C++, Python, C#

Gamma: C++, Python, C#

Inverse gamma: C++, C#

Laplace: C++, C#

Log normal: C++, C#

Normal: C++, Python, C#

Poisson: C++

Student-t: C++, Python, C#

Uniform: C++, C#

Weibull: C++, C#

C++ TR1 has code for generting 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.

See this page for Non-uniform random number generation in Julia.

The article Simple Random Number Generation gives self-contained C# code for generating from the distributions above as well as from Laplace, inverse gamma, and Weibull distributions.

 

Miscellaneous

Distance based on longitude and latitude: Python, F#

 

Home