https://github.com/qbarthelemy/stats-simple-cpp
Library for statistics in simple C++, for different sequence containers of different numeric data types.
https://github.com/qbarthelemy/stats-simple-cpp
c-plus-plus cplusplus machine-learning scientific-computing statistics
Last synced: about 1 year ago
JSON representation
Library for statistics in simple C++, for different sequence containers of different numeric data types.
- Host: GitHub
- URL: https://github.com/qbarthelemy/stats-simple-cpp
- Owner: qbarthelemy
- Created: 2021-12-01T21:17:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T21:07:56.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T14:12:29.031Z (over 1 year ago)
- Topics: c-plus-plus, cplusplus, machine-learning, scientific-computing, statistics
- Language: C++
- Homepage:
- Size: 34.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# stats-simple-cpp
[](https://img.shields.io/badge/C++-11+-blue)
[](https://img.shields.io/badge/license-BSD--3--Clause-green)
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](https://github.com/numpy/numpy) and
[SciPy](https://github.com/scipy/scipy), and some classes of
[scikit-learn](https://github.com/scikit-learn/scikit-learn) with:
- simple Python-like syntax;
- simple C++ code (compatible from C++11);
- simple dependencies (use only [C++ Standard Library](https://en.cppreference.com/w/cpp/header),
no advanced dependencies like [boost](https://github.com/boostorg/boost),
[mlpack](https://github.com/mlpack/mlpack)
or [Eigen](https://gitlab.com/libeigen/eigen));
- generic templated functions, compatible for different
[sequence containers](https://en.cppreference.com/w/cpp/named_req/SequenceContainer)
(`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
int main()
{
std::list 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.