Skip to content

Library for statistics in simple C++, for different sequence containers of different numeric data types.

Notifications You must be signed in to change notification settings

qbarthelemy/stats-simple-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

stats-simple-cpp

Code CppVersion License

Library of statistical functions and classes in simple C++, compatible for different sequence containers of different numeric data types.

Description

The goal of this header-only library is to mimic some functions of NumPy and SciPy, and some classes of scikit-learn with:

  • simple Python-like syntax;
  • simple C++ code (compatible from C++11);
  • simple dependencies (use only C++ Standard Library, no advanced dependencies like boost, mlpack or Eigen);
  • generic templated functions, compatible for different sequence containers (std::list, std::vector, std::deque) of different numeric data types (unsigned int, int, float, double).

Content

Maths.hpp

Integer input functions: gcd, factorial

Checking functions: is_positive

Aggregation functions: prod

Element-wise functions: linear, absolute, reciprocal, power, log, exp, sigmoid

Others: set

Stats.hpp

Summary statistics: mean, hmean, gmean, pmean, var, std, hstd, gstd, skewness, kurtosis, median, median_abs_deviation

Transformations: center, zscore, gzscore

Correlation functions: pearsonr, spearmanr

Metrics: accuracy_score

Others: rankdata

CSimpleLinearRegression.hpp

Class SimpleLinearRegression, with fit, predict, and score (coefficient of determination R²).

CSimpleLogisticRegression.hpp

Class SimpleLogisticRegression for binary classification, with fit, predict, and score (accuracy).

Example

#include "CSimpleLinearRegression.hpp"
#include <list>

int main()
{
	std::list<double> x = { 5.1, 13, -5, 17.5, 8 }, y = { -2, 3, 7.2, 10, -1 };
	SimpleLinearRegression slr = SimpleLinearRegression();
	slr.fit(x, y);
	x = { 42 };
	y = slr.predict(x);
}

Contributing

Code must be compliant with all features listed in Description.

About

Library for statistics in simple C++, for different sequence containers of different numeric data types.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages