Skip to content

Commit 4dd8bc3

Browse files
committed
version 3.1.0
1 parent b063000 commit 4dd8bc3

File tree

320 files changed

+1761
-816
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

320 files changed

+1761
-816
lines changed

.readthedocs.requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
sphinx == 1.8.1
2-
breathe
3-
sphinxcontrib-katex
1+
sphinx == 2.4.4
2+
breathe == 4.11.0
3+
sphinxcontrib-katex == 0.6.0

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
StatsLib: A C++ Library of Statistical Distribution Functions
2-
Copyright 2011-2019 Keith O'Hara
2+
Copyright 2011-2020 Keith O'Hara
33

44
This product includes software developed by Keith O'Hara (http://www.kthohr.com)

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
StatsLib is a templated C++ library of statistical distribution functions featuring unique compile-time computing capabilities and seamless integration with several popular linear algebra libraries.
5+
StatsLib is a templated C++ library of statistical distribution functions, featuring unique compile-time computing capabilities and seamless integration with several popular linear algebra libraries.
66

77
Features:
88
* A header-only library of probability density functions, cumulative distribution functions, quantile functions, and random sampling methods.
@@ -77,7 +77,7 @@ The following options should be declared **before** including the StatsLib heade
7777
#define STATS_GO_INLINE
7878
```
7979

80-
* OpenMP functionality is enabled by default if the `_OPENMP` macro is detected (e.g., by invoking `-fopenmp` with a GCC or Clang compiler). To explicitly enable OpenMP features use:
80+
* OpenMP functionality is enabled by default if the `_OPENMP` macro is detected (e.g., by invoking `-fopenmp` with GCC or Clang). To explicitly enable OpenMP features use:
8181
```cpp
8282
#define STATS_USE_OPENMP
8383
```
@@ -131,7 +131,7 @@ All of these functions have matrix-based equivalents using Armadillo, Blaze, and
131131
arma::mat norm_pdf_vals = stats::dnorm(arma::ones(10,20),1.0,2.0);
132132
```
133133

134-
* The randomization functions (`r*`) can output random matrices of arbitrary size. For example,</li>
134+
* The randomization functions (`r*`) can output random matrices of arbitrary size. For example, For example, the following code will generate a 100-by-50 matrix of iid draws from a Gamma(3,2) distribution:</li>
135135

136136
```cpp
137137
// Armadillo:
@@ -141,13 +141,12 @@ blaze::DynamicMatrix<double> gamma_rvs = stats::rgamma<blaze::DynamicMatrix<doub
141141
// Eigen:
142142
Eigen::MatrixXd gamma_rvs = stats::rgamma<Eigen::MatrixXd>(100,50,3.0,2.0);
143143
```
144-
&nbsp; &nbsp; &nbsp; &nbsp; will generate a 100-by-50 matrix of iid draws from a Gamma(3,2) distribution.
145144

146145
* All matrix-based operations are parallelizable with OpenMP. For GCC and Clang compilers, simply include the `-fopenmp` option during compilation.
147146

148-
### Seeding
147+
### Seeding Values
149148

150-
Random number seeding is available in two formats: seed values and random number engines.
149+
Random number seeding is available in two forms: seed values and random number engines.
151150

152151
* Seed values are passed as unsigned integers. For example, to generate a draw from a normal distribution N(1,2) with seed value 1776:
153152
``` cpp
@@ -188,7 +187,7 @@ arma::mat beta_cdf_vals = stats::pbeta(beta_rvs,3.0,2.0);
188187

189188
StatsLib is designed to operate equally well as a compile-time computation engine. Compile-time computation allows the compiler to replace function calls (e.g., `dnorm(0,0,1)`) with static values in the source code. That is, functions are evaluated during the compilation process, rather than at run-time. This capability is made possible due to the templated `constexpr` design of the library and can be verified by inspecting the assembly code generated by the compiler.
190189

191-
The compile-time features are enabled using the `constexpr` specifier. The example below computes the pdf, cdf, and quantile function of the Laplace distribution:
190+
The compile-time features are enabled using the `constexpr` specifier. The example below computes the pdf, cdf, and quantile function of the Laplace distribution.
192191
```cpp
193192
#include "stats.hpp"
194193

binder/environment.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# For use with Binder
22
name: statslib
33
channels:
4-
- QuantStack
54
- conda-forge
65
dependencies:
7-
- xeus-cling=0.4.7
6+
- xeus-cling=0.8.1
87
- notebook

docs/Doxyfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ MACRO_EXPANSION = YES
1717
EXPAND_ONLY_PREDEF = YES
1818
PREDEFINED = "statslib_constexpr=constexpr" \
1919
"statslib_inline=inline" \
20+
"STATS_ENABLE_INTERNAL_VEC_FEATURES" \
2021
"STATS_ENABLE_STDVEC_WRAPPERS" \
2122
"STATS_ENABLE_ARMA_WRAPPERS" \
2223
"STATS_ENABLE_BLAZE_WRAPPERS" \

docs/source/api/bernoulli.rst

Lines changed: 63 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. Copyright (c) 2011--2018 Keith O'Hara
1+
.. Copyright (c) 2011-2020 Keith O'Hara
22
33
Distributed under the terms of the Apache License, Version 2.0.
44
@@ -7,14 +7,22 @@
77
Bernoulli Distribution
88
======================
99

10+
**Table of contents**
11+
12+
.. contents:: :local:
13+
14+
----
15+
16+
Density Function
17+
----------------
18+
1019
The density function of the Bernoulli distribution:
1120

1221
.. math::
1322
1423
f(x; p) = p^x (1-p)^{1-x} \times \mathbf{1}[x \in \{0,1\}]
1524
16-
PDF
17-
---
25+
Methods for scalar input, as well as for vector/matrix input, are listed below.
1826

1927
Scalar Input
2028
~~~~~~~~~~~~
@@ -26,32 +34,46 @@ Scalar Input
2634
Vector/Matrix Input
2735
~~~~~~~~~~~~~~~~~~~
2836

29-
1. STL Containers
37+
STL Containers
38+
______________
3039

3140
.. _dbern-func-ref2:
3241
.. doxygenfunction:: dbern(const std::vector<eT>&, const T1, const bool)
3342
:project: statslib
3443

35-
2. Armadillo
44+
Armadillo
45+
_________
3646

3747
.. _dbern-func-ref3:
3848
.. doxygenfunction:: dbern(const ArmaMat<eT>&, const T1, const bool)
3949
:project: statslib
4050

41-
3. Blaze
51+
Blaze
52+
_____
4253

4354
.. _dbern-func-ref4:
4455
.. doxygenfunction:: dbern(const BlazeMat<eT, To>&, const T1, const bool)
4556
:project: statslib
4657

47-
4. Eigen
58+
Eigen
59+
_____
4860

4961
.. _dbern-func-ref5:
5062
.. doxygenfunction:: dbern(const EigenMat<eT, iTr, iTc>&, const T1, const bool)
5163
:project: statslib
5264

53-
CDF
54-
---
65+
----
66+
67+
Cumulative Distribution Function
68+
--------------------------------
69+
70+
The cumulative distribution function of the Bernoulli distribution:
71+
72+
.. math::
73+
74+
F(x; p) = \sum_{z \leq x} f(z; p) = \begin{cases} 0 & \text{ if } x < 0 \\ 1-p & \text{ if } 0 \leq x < 1 \\ 1 & \text{ if } x \geq 1 \end{cases}
75+
76+
Methods for scalar input, as well as for vector/matrix input, are listed below.
5577

5678
Scalar Input
5779
~~~~~~~~~~~~
@@ -63,32 +85,46 @@ Scalar Input
6385
Vector/Matrix Input
6486
~~~~~~~~~~~~~~~~~~~
6587

66-
1. STL Containers
88+
STL Containers
89+
______________
6790

6891
.. _pbern-func-ref2:
6992
.. doxygenfunction:: pbern(const std::vector<eT>&, const T1, const bool)
7093
:project: statslib
7194

72-
2. Armadillo
95+
Armadillo
96+
_________
7397

7498
.. _pbern-func-ref3:
7599
.. doxygenfunction:: pbern(const ArmaMat<eT>&, const T1, const bool)
76100
:project: statslib
77101

78-
3. Blaze
102+
Blaze
103+
_____
79104

80105
.. _pbern-func-ref4:
81106
.. doxygenfunction:: pbern(const BlazeMat<eT, To>&, const T1, const bool)
82107
:project: statslib
83108

84-
4. Eigen
109+
Eigen
110+
_____
85111

86112
.. _pbern-func-ref5:
87113
.. doxygenfunction:: pbern(const EigenMat<eT, iTr, iTc>&, const T1, const bool)
88114
:project: statslib
89115

90-
Quantile
91-
--------
116+
----
117+
118+
Quantile Function
119+
-----------------
120+
121+
The quantile function of the Bernoulli distribution:
122+
123+
.. math::
124+
125+
q(r; p) = \begin{cases} 0 & \text{ if } r \leq 1 - p \\ 1 & \text{ else } \end{cases}
126+
127+
Methods for scalar input, as well as for vector/matrix input, are listed below.
92128

93129
Scalar Input
94130
~~~~~~~~~~~~
@@ -100,33 +136,41 @@ Scalar Input
100136
Vector/Matrix Input
101137
~~~~~~~~~~~~~~~~~~~
102138

103-
1. STL Containers
139+
STL Containers
140+
______________
104141

105142
.. _qbern-func-ref2:
106143
.. doxygenfunction:: qbern(const std::vector<eT>&, const T1)
107144
:project: statslib
108145

109-
2. Armadillo
146+
Armadillo
147+
_________
110148

111149
.. _qbern-func-ref3:
112150
.. doxygenfunction:: qbern(const ArmaMat<eT>&, const T1)
113151
:project: statslib
114152

115-
3. Blaze
153+
Blaze
154+
_____
116155

117156
.. _qbern-func-ref4:
118157
.. doxygenfunction:: qbern(const BlazeMat<eT, To>&, const T1)
119158
:project: statslib
120159

121-
4. Eigen
160+
Eigen
161+
_____
122162

123163
.. _qbern-func-ref5:
124164
.. doxygenfunction:: qbern(const EigenMat<eT, iTr, iTc>&, const T1)
125165
:project: statslib
126166

167+
----
168+
127169
Random Sampling
128170
---------------
129171

172+
Random sampling for the Bernoulli distribution is achieved via the inverse probability integral transform.
173+
130174
Scalar Output
131175
~~~~~~~~~~~~~
132176

0 commit comments

Comments
 (0)