GSL-RANDIST *********** .. current-library:: dylan-gsl .. current-module:: gsl-randist This module provides functionality to generate random variates from distributions. Polymorphism and multimethods were used to simplify the original GSL library interface, reducing both the function count and the number of parameters per function. See :class:`` for examples of this design. The distributions available in this module are: - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` The ```` interface =============================== .. class:: :abstract: :uninstantiable: Base class for all distributions. :keyword rng: Random number generator. Used to generate random variates from the distribution. If not provided a new instance of :class:`` is provided. This generator can be configured by environment variables (see :ref:`rng_environment_variables`) :operations: - :func:`gsl-randist-variate` - :func:`gsl-randist-pdf` Operations ---------- .. generic-function:: gsl-randist-variate :signature: gsl-randist-variate distribution => (variate) Generates a random variate from the distribution. :parameter distribution: An instance of :class:``. :result variate: A random variate from the distribution. An instance of :drm:``. .. generic-function:: gsl-randist-pdf Evaluates the probability density function (PDF) for the distribution. :signature: gsl-randist-pdf (distribution, x) => (pd) :parameter distribution: An instance of :class:``. :parameter x: The value at which to evaluate the probability density function. An instance of :drm:``. :result pd: The probability density at x. An instance of :drm:``. The Continuous Distribution =========================== .. class:: :abstract: :uninstantiable: :supers: :class:`` Base class for all continuous distributions. :operations: - :func:`gsl-randist-variate` - :func:`gsl-randist-pdf` - :func:`gsl-randist-cdf-p` - :func:`gsl-randist-cdf-q` - :func:`gsl-randist-cdf-pinv` - :func:`gsl-randist-cdf-qinv` The Continuous distributions available are: - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` - :class:`` .. generic-function:: gsl-randist-cdf-p Evaluates the cumulative distribution function (CDF) for the distribution. :signature: gsl-randist-cdf-p distribution x => (cd) :parameter distribution: An instance of :class:``. :parameter x: The value at which to evaluate the cumulative distribution function. An instance of :drm:``. :result cd: The cumulative probability at x. An instance of :drm:``. .. generic-function:: gsl-randist-cdf-q :signature: gsl-randist-cdf-q distribution x => (cd) :parameter distribution: An instance of :class:``. :parameter x: The value at which to evaluate the survival function. An instance of :drm:``. :result cd: The survival function at x. An instance of :drm:``. .. generic-function:: gsl-randist-cdf-pinv Evaluates the inverse cumulative distribution function (CDF) for the distribution. :signature: gsl-randist-cdf-pinv distribution x => (cd) :parameter distribution: An instance of :class:``. :parameter x: The value at which to evaluate the inverse cumulative distribution function. An instance of :drm:``. :result cd: The inverse cumulative distribution function at x. An instance of :drm:``. .. generic-function:: gsl-randist-cdf-qinv Evaluates the inverse cumulative distribution function (CDF) for the distribution. :signature: gsl-randist-cdf-qinv distribution x => (cd) :parameter distribution: An instance of :class:``. :parameter x: The value at which to evaluate the inverse survival function. An instance of :drm:``. :result cd: The inverse survival function at x. An instance of :drm:``. The Gaussian Distribution ========================= .. class:: :instantiable: :concrete: A Gaussian distribution. This returns random values of Gaussian probability density function. See the original GSL documentation for more information at `Gaussian Distribution `_. This distribution stores the type of algorithm used to generate random variates. :supers: :class:`` :keyword required sigma: Standard deviation. An instance of :drm:``. :keyword algorithm: The algorithm to use for generating random variates. See :ref:`gaussian-algorithms` for more information. :conditions: A :class:`` condition is raised if the algorithm is not one of ````. :example: .. code-block:: dylan let r = make(); let d = make(, sigma: 0.5d0, rng: r); let k = d.gsl-randist-variate; :example: .. code-block:: dylan let d = make(, rng: make(), sigma: 0.5d0, algorithm: #"ratio"); let k = d.gsl-randist-variate; :seealso: https://www.gnu.org/software/gsl/doc/html/randist.html#the-gaussian-distribution The following operations are defined for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Unit Gaussian distribution ============================== .. class:: :instantiable: :concrete: Unit Gaussian is a Gaussian distribution with sigma = 1.0d0. :supers: :class:`` :key algorithm: The algorithm to use for generating random variates. See :ref:`gaussian-algorithms` for more information. :discussion: The keyword ``sigma:`` must not be used since it is initialized by the class. :example: .. code-block:: dylan let d = make(, rng: make()); let v = d.gsl-randist-variate; :seealso: - :class:`` .. _gaussian-algorithms: Gaussian algorithms ------------------- .. class:: This are the algorithms to generate a Gaussian variate value. This algorithm is passed as an optional keyword ``algorithm:`` to :class:`` class. The valid values are: ``#"box-muller`` Box-Muller algorithm. This is the default value. ``#"ziggurat"`` Computes a Gaussian random variate using the alternative Marsaglia-Tsang ziggurat method. The Ziggurat algorithm is the fastest available algorithm in most cases. ``#"ratio-method"`` Kinderman-Monahan-Leva ratio method. The Gaussian tail distribution ============================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required rng: :keyword required sigma: :keyword required a: An instance of :drm:``. The values returned are larger than this limit, which must be positive. :conditions: A :class:`` is signaled if ``a`` keyword is not positive. :summary: Provides random variates from the upper tail of a Gaussian distribution with standard deviation ``sigma``. The values returned are larger than the lower limit ``a``, which must be positive. :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-gaussian-tail-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: The Ugaussian tail distribution =============================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required rng: :keyword required a: An instance of :drm:``. The values returned are larger than this limit, which must be positive. :summary: Compute results for the tail of a unit Gaussian distribution. They are equivalent to the :class:`` with a standard deviation of one, ``sigma`` = 1.0d0. The Exponential Distribution ============================ .. class:: :instantiable: :concrete: :supers: :class:``` :keyword required mu: Mean mu. :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-exponential-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Laplace Distribution ======================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required a: Width :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-laplace-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Exponential Power Distribution ================================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required a: An instance of :drm:`` :keyword required b: An instance of :drm:`` :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-exponential-power-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: The Cauchy Distribution ======================= .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required a: Scale parameter. An instance of :drm:`` :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-cauchy-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Rayleigh Distribution ========================= .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required sigma: An instance of :drm:`` :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-rayleigh-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: The Rayleigh Tail distribution ============================== .. class:: :supers: :class:`` :keyword required rng: :keyword required sigma: Scale parameter. An instance of :drm:``. :keyword required a: An instance of :drm:``. Lower limit. The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: The Landau distribution ======================= .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required rng: The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: The Levy alpha-Stable Distribution ================================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required rng: :keyword required c: Scale. An instance of :class:``. :keyword required alpha: Scale. An instance of :class:``. The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: The Levy skew alpha-Stable Distribution ======================================= .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required rng: :keyword required c: Scale. An instance of :class:``. :keyword required alpha: Scale. An instance of :class:``. :keyword required beta: Skew. An instance of :class:``. The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: The Gamma Distribution ====================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword algorithm: The algorithm to use for generating random variates. See :ref:`gamma-algorithms` for more information. :keyword required a: a > 0 :keyword required b: b > 0 :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-gamma-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: .. _gamma-algorithms: Gamma algorithms ---------------- .. class:: This are the algorithms to generate a Gamma variate value. This algorithm is passed as an optional keyword ``algorithm:`` to :class:`` class. The valid values are: ``#"default"`` This is the default value. ``#"knuth"`` This function returns a gamma variate using the algorithms from Knuth (vol 2). The Flat Distribution ====================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required a: Lower limit. An instance of :drm:`` :keyword required b: Upper limit. An instance of :drm:`` :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-flat-distribution :discussion: Returns a random variate from the flat (uniform) distribution from a to b The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Lognormal Distribution ========================== .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required zeta: An instance of :drm:`` :keyword required sigma: An instance of :drm:`` :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-lognormal-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: The Chi-Squared Distribution ============================ .. class:: :instantiable: :concrete: :supers: :class:`` :keyword required nu: Degrees of freedom. An instance of :drm:`` :example: .. code-block:: dylan let r = make(); let d = make(, nu: 3.0d0, rng: r); let k = d.gsl-randist-variate; :seealso: - https://www.gnu.org/software/gsl/doc/html/randist.html#the-chi-squared-distribution The following operations are specialized for :class:``. See operations in :class:`` for more information. .. method:: gsl-randist-variate :specializer: :no-contents-entry: .. method:: gsl-randist-pdf :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-p :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-q :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-pinv :specializer: :no-contents-entry: .. method:: gsl-randist-cdf-qinv :specializer: :no-contents-entry: