.. Copyright 2020 Intel Corporation
..
.. Licensed under the Apache License, Version 2.0 (the "License");
.. you may not use this file except in compliance with the License.
.. You may obtain a copy of the License at
..
..     http://www.apache.org/licenses/LICENSE-2.0
..
.. Unless required by applicable law or agreed to in writing, software
.. distributed under the License is distributed on an "AS IS" BASIS,
.. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
.. See the License for the specific language governing permissions and
.. limitations under the License.

.. _distributions:

Distributions
=============

Random number distribution generators are used to generate random numbers with different types
of the discrete and continuous distributions. The numbers are generated by transforming uniformly
distributed variates in accordance with the required cumulative distribution function (CDF).

In |short_name|, distribution represents an algorithm interface that runs in-place initialization
of memory according to the required CDF.

.. toctree::
   :maxdepth: 1

   uniform.rst
   normal.rst
   bernoulli.rst

.. rubric:: Algorithm Input

Distribution algorithms accept the input described below.
Pass the ``Input ID`` as a parameter to the methods that provide input for your algorithm.
For more details, see :ref:`algorithms`.

.. tabularcolumns::  |\Y{0.2}|\Y{0.8}|

.. list-table:: Algorithm Input for Distributions
   :widths: 10 60
   :header-rows: 1

   * - Input ID
     - Input
   * - ``tableToFill``
     - Pointer to the numeric table of size :math:`n \times p`.

       .. note::
          This input can be an object of any class derived from ``NumericTable``
          except ``CSRNumericTable``, ``PackedSymmetricMatrix``, ``PackedTriangularMatrix``, and ``MergedNumericTable``
          when it holds one of the above table types.

.. rubric:: Algorithm Parameters

Distribution algorithms have the following common parameter:

.. tabularcolumns::  |\Y{0.10}|\Y{0.6}|\Y{0.3}|

.. list-table:: Algorithm Parameters for Distributions
   :header-rows: 1
   :widths: 10 30 30
   :align: left

   * - Parameter
     - Default Value
     - Description
   * - ``engine``
     - `SharePtr< engines:: mt19937:: Batch>()`
     - Pointer to the random number engine.

.. rubric:: Algorithm Output

Distribution algorithms calculate the result described below.
Pass the ``Result ID`` as a parameter to the methods that access the results of your algorithm.
For more details, see :ref:`algorithms`.

.. tabularcolumns::  |\Y{0.2}|\Y{0.8}|

.. list-table:: Algorithm Output for Distributions
   :widths: 10 60
   :header-rows: 1

   * - Result ID
     - Result
   * - ``randomNumbers``
     - Pointer to the :math:`n \times p` numeric table with algorithm results.

       In |short_name|, distribution algorithms are in-place,
       which means that the algorithm does not allocate memory for the distribution result,
       but returns pointer to the filled input.
