Best Library for Statistics in C++

Best stats library for C (not C++)

gsl ( is widely available, portable, and has a lot of nice functionality.

c library for computing mean, median, mode, other statistics?

GNU Scientific Library (GSL) provides the functionality. Apophenia mentioned by another appears to provide a layer on top of GSL. Something to bear in mind with GSL is that it is frequently a slow implementation of many functions. For instance, its mean calculations perform division inside the loop to ensure best possible precision of the result. In many applications this cost is not worth the precision.

Statistic Library for Objective C

Check out C/C++ libraries: wikipedia list, SO question.

What is a good statistical math package for .Net?

MathDotNet should have the functions you are looking for, although it may be a bit of overkill depending on how much functionality you need.
It offers:

  • Bernoulli
  • Beta
  • Binomial
  • Categorical
  • Cauchy
  • Chi
  • Chi Square
  • Continuous Uniform
  • Conway Maxwell Poisson
  • Dirichlet
  • Discrete Uniform
  • Erlang
  • Exponential
  • etc.... (about 3x more on the list)

For a complete list see this page.

Recommend an Open Source .NET Statistics Library

I found this on the CodeProject website. It looks like a good C# class for handling most of the basic statistical functions.


Any C++ data mining library which also have the support of mysql?

Use this source to find a suitable ML C++ library:

  • filtered by C++

Some recommended ML libraries for C++ :

  • Shark
  • Shogun
  • libSVM
  • DLIB
  • Waffles
  • GibbsLDA++

See this related question.

C probability library similar to R

You can always embed R itself in your C application. That is doable, and documented, but a tad tedious as the API is pretty bare.

If you are open to C++, it gets much easier thanks to RInside. If you can do this in R:

R> set.seed(123); sample(LETTERS[1:5], 10, replace=TRUE)
[1] "B" "D" "C" "E" "E" "A" "C" "E" "C" "C"

you can do the same in C++ pretty easily thanks to RInside:

edd@max:~/svn/rinside/pkg/inst/examples/standard$ cat rinside_sample12.cpp
// Simple example motivated by StackOverflow question on using sample() from C
// Copyright (C) 2012 Dirk Eddelbuettel and Romain Francois

#include <RInside.h> // for the embedded R via RInside

int main(int argc, char *argv[]) {

RInside R(argc, argv); // create an embedded R instance

std::string cmd = "set.seed(123); sample(LETTERS[1:5], 10, replace=TRUE)";

Rcpp::CharacterVector res = R.parseEval(cmd); // parse, eval + return result

for (int i=0; i<res.size(); i++) {
std::cout << res[i] << " ";
std::cout << std::endl;



and given that it runs the same code with the same RNG seed it also returns the same result:

edd@max:~/svn/rinside/pkg/inst/examples/standard$ ./rinside_sample12

If you just drop the code I showed above into the directory examples/standard of an existing RInside installation and say make, the executable will be made and given the same basename as your source file (here rinside_sample12 from rinside_sample12.cpp).

How to use C libraries in Vlang for basic statistics

Yes, you can call C libraries from V.

You need to make the C library's structs, typedefs and functions known to V by defining them in V first - before calling/using them.

For structs you conveniently only need to define the fields you need to use.

Here's some examples:

  • via 2D game framework wrapping several C libs
  • sokol in vlib
  • v-miniaudio wrapper (disclaimer: my own module)

Generally you can find a lot of C wrapper code in vlib itself. (We're working on replacing C with pure V)

Related Topics

Leave a reply