Skip to content

Commit

Permalink
version 3.4.0
Browse files Browse the repository at this point in the history
- add Rademacher distribution
- minor fix to rlogis header
  • Loading branch information
kthohr committed Apr 23, 2023
1 parent f8f30f8 commit 72e911e
Show file tree
Hide file tree
Showing 26 changed files with 1,787 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Functions to compute the cdf, pdf, quantile, as well as random sampling methods,
* Log-Normal
* Normal (Gaussian)
* Poisson
* Rademacher
* Student's t
* Uniform
* Weibull
Expand Down
4 changes: 4 additions & 0 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ INPUT = ../include/stats_incl/dens/dbern.hpp \
../include/stats_incl/dens/dmvnorm.hpp \
../include/stats_incl/dens/dnorm.hpp \
../include/stats_incl/dens/dpois.hpp \
../include/stats_incl/dens/dradem.hpp \
../include/stats_incl/dens/dt.hpp \
../include/stats_incl/dens/dunif.hpp \
../include/stats_incl/dens/dweibull.hpp \
Expand All @@ -36,6 +37,7 @@ INPUT = ../include/stats_incl/dens/dbern.hpp \
../include/stats_incl/prob/plogis.hpp \
../include/stats_incl/prob/pnorm.hpp \
../include/stats_incl/prob/ppois.hpp \
../include/stats_incl/prob/pradem.hpp \
../include/stats_incl/prob/pt.hpp \
../include/stats_incl/prob/punif.hpp \
../include/stats_incl/prob/pweibull.hpp \
Expand All @@ -54,6 +56,7 @@ INPUT = ../include/stats_incl/dens/dbern.hpp \
../include/stats_incl/quant/qlogis.hpp \
../include/stats_incl/quant/qnorm.hpp \
../include/stats_incl/quant/qpois.hpp \
../include/stats_incl/quant/qradem.hpp \
../include/stats_incl/quant/qt.hpp \
../include/stats_incl/quant/qunif.hpp \
../include/stats_incl/quant/qweibull.hpp \
Expand All @@ -74,6 +77,7 @@ INPUT = ../include/stats_incl/dens/dbern.hpp \
../include/stats_incl/rand/rmvnorm.hpp \
../include/stats_incl/rand/rnorm.hpp \
../include/stats_incl/rand/rpois.hpp \
../include/stats_incl/rand/rradem.hpp \
../include/stats_incl/rand/rt.hpp \
../include/stats_incl/rand/runif.hpp \
../include/stats_incl/rand/rweibull.hpp \
Expand Down
15 changes: 15 additions & 0 deletions docs/source/api/dist_index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,21 @@ Distributions
| :ref:`rpois <rpois-func-ref1>` | random sampling function of the Poisson distribution |
+----------------------------------------+--------------------------------------------------------------+

.. toctree::
:maxdepth: 2

rademacher

+----------------------------------------+--------------------------------------------------------------+
| :ref:`dradem <dradem-func-ref1>` | density function of the Rademacher distribution |
+----------------------------------------+--------------------------------------------------------------+
| :ref:`pradem <pradem-func-ref1>` | distribution function of the Rademacher distribution |
+----------------------------------------+--------------------------------------------------------------+
| :ref:`qradem <qradem-func-ref1>` | quantile function of the Rademacher distribution |
+----------------------------------------+--------------------------------------------------------------+
| :ref:`rradem <rradem-func-ref1>` | random sampling function of the Rademacher distribution |
+----------------------------------------+--------------------------------------------------------------+

.. toctree::
:maxdepth: 2

Expand Down
205 changes: 205 additions & 0 deletions docs/source/api/rademacher.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
.. Copyright (c) 2011-2023 Keith O'Hara
Distributed under the terms of the Apache License, Version 2.0.
The full license is in the file LICENSE, distributed with this software.
Rademacher Distribution
=======================

**Table of contents**

.. contents:: :local:

----

Density Function
----------------

The density function of the Rademacher distribution:

.. math::
f(x; p) = p \times \mathbf{1}[x = 1] + (1-p) \times \mathbf{1}[x = -1]
Note that this is a somewhat more general definition of the Rademacher distribution than is standard in the statistics literature,
which assumes :math:`p = 0.5`.

Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input
~~~~~~~~~~~~

.. _dradem-func-ref1:
.. doxygenfunction:: dradem(const llint_t x, const T prob_par, const bool log_form)
:project: statslib

Vector/Matrix Input
~~~~~~~~~~~~~~~~~~~

STL Containers
______________

.. _dradem-func-ref2:
.. doxygenfunction:: dradem(const std::vector<eT>& x, const T1 prob_par, const bool log_form)
:project: statslib

Armadillo
_________

.. _dradem-func-ref3:
.. doxygenfunction:: dradem(const ArmaGen<mT,tT>& X, const T1 prob_par, const bool log_form)
:project: statslib

Blaze
_____

.. _dradem-func-ref4:
.. doxygenfunction:: dradem(const BlazeMat<eT,To>& X, const T1 prob_par, const bool log_form)
:project: statslib

Eigen
_____

.. _dradem-func-ref5:
.. doxygenfunction:: dradem(const EigenMat<eT,iTr,iTc>& X, const T1 prob_par, const bool log_form)
:project: statslib

----

Cumulative Distribution Function
--------------------------------

The cumulative distribution function of the Rademacher distribution:

.. math::
F(x; p) = \sum_{z \leq x} f(z; p) = \begin{cases} 0 & \text{ if } x < -1 \\ 1-p & \text{ if } x < 1 \\ 1 & \text{ if } x \geq 1 \end{cases}
Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input
~~~~~~~~~~~~

.. _pradem-func-ref1:
.. doxygenfunction:: pradem(const llint_t, const T, const bool)
:project: statslib

Vector/Matrix Input
~~~~~~~~~~~~~~~~~~~

STL Containers
______________

.. _pradem-func-ref2:
.. doxygenfunction:: pradem(const std::vector<eT>&, const T1, const bool)
:project: statslib

Armadillo
_________

.. _pradem-func-ref3:
.. doxygenfunction:: pradem(const ArmaMat<eT>&, const T1, const bool)
:project: statslib

Blaze
_____

.. _pradem-func-ref4:
.. doxygenfunction:: pradem(const BlazeMat<eT, To>&, const T1, const bool)
:project: statslib

Eigen
_____

.. _pradem-func-ref5:
.. doxygenfunction:: pradem(const EigenMat<eT, iTr, iTc>&, const T1, const bool)
:project: statslib

----

Quantile Function
-----------------

The quantile function of the Rademacher distribution:

.. math::
q(r; p) = \begin{cases} -1 & \text{ if } r \leq 1 - p \\ 1 & \text{ else } \end{cases}
Methods for scalar input, as well as for vector/matrix input, are listed below.

Scalar Input
~~~~~~~~~~~~

.. _qradem-func-ref1:
.. doxygenfunction:: qradem(const T1, const T2)
:project: statslib

Vector/Matrix Input
~~~~~~~~~~~~~~~~~~~

STL Containers
______________

.. _qradem-func-ref2:
.. doxygenfunction:: qradem(const std::vector<eT>&, const T1)
:project: statslib

Armadillo
_________

.. _qradem-func-ref3:
.. doxygenfunction:: qradem(const ArmaMat<eT>&, const T1)
:project: statslib

Blaze
_____

.. _qradem-func-ref4:
.. doxygenfunction:: qradem(const BlazeMat<eT, To>&, const T1)
:project: statslib

Eigen
_____

.. _qradem-func-ref5:
.. doxygenfunction:: qradem(const EigenMat<eT, iTr, iTc>&, const T1)
:project: statslib

----

Random Sampling
---------------

Random sampling for the Rademacher distribution is achieved via the inverse probability integral transform.

Scalar Output
~~~~~~~~~~~~~

1. Random number engines

.. _rradem-func-ref1:
.. doxygenfunction:: rradem(const T, rand_engine_t&)
:project: statslib

2. Seed values

.. _rradem-func-ref2:
.. doxygenfunction:: rradem(const T, const ullint_t)
:project: statslib

Vector/Matrix Output
~~~~~~~~~~~~~~~~~~~~

1. Random number engines

.. _rradem-func-ref3:
.. doxygenfunction:: rradem(const ullint_t, const ullint_t, const T1, rand_engine_t&)
:project: statslib

2. Seed values

.. _rradem-func-ref4:
.. doxygenfunction:: rradem(const ullint_t, const ullint_t, const T1, const ullint_t)
:project: statslib
1 change: 1 addition & 0 deletions include/stats_incl/dens/dens.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "dmvnorm.hpp"
#include "dnorm.hpp"
#include "dpois.hpp"
#include "dradem.hpp"
#include "dt.hpp"
#include "dunif.hpp"
#include "dweibull.hpp"
Expand Down
Loading

0 comments on commit 72e911e

Please sign in to comment.