library.rand Submodule

Module Summary

Interfaces for the NAG Mark 30.2 rand Chapter.

rand - Random Number Generators

This module is concerned with the generation of sequences of independent pseudorandom and quasi-random numbers from various distributions, and models.

See Also

naginterfaces.library.examples.rand :

This subpackage contains examples for the rand module. See also the Examples subsection.

Functionality Index

Brownian bridge

circulant embedding generator

generate fractional Brownian motion: field_fracbm_generate()

increments generator

generate Wiener increments: bb_inc()

initialize generator: bb_inc_init()

path generator

create bridge construction order: bb_make_bridge_order()

generate a free or non-free (pinned) Wiener process for a given set of time steps: bb()

initialize generator: bb_init()

Generating samples, matrices and tables

permutation of real matrix, vector, vector triplet

fold cross-validation: kfold_xyw()

random sub-sampling validation: subsamp_xyw()

random correlation matrix: matrix_corr()

random orthogonal matrix: matrix_orthog()

random permutation of an integer vector: permute()

random sample from an integer vector

unequal weights, without replacement: sample_wgt()

unweighted, without replacement: sample()

random table: matrix_2waytable()

resample from an integer vector

unequal weights: resample()

Generation of time series

asymmetric GARCH Type II: times_garch_asym2()

asymmetric GJR GARCH: times_garch_gjr()

EGARCH: times_garch_exp()

exponential smoothing: times_smooth_exp()

type I AGARCH: times_garch_asym1()

univariate ARMA: times_arma()

vector ARMA: times_mv_varma()

Pseudorandom numbers

array of variates from multivariate distributions

Dirichlet distribution: dist_dirichlet()

multinomial distribution: int_multinomial()

Normal distribution: multivar_normal()

Student’s distribution: multivar_students_t()

copulas

Clayton/Cook–Johnson copula (bivariate): copula_clayton_bivar()

Clayton/Cook–Johnson copula (multivariate): copula_clayton()

Frank copula (bivariate): copula_frank_bivar()

Frank copula (multivariate): copula_frank()

Gaussian copula: copula_normal()

Gumbel–Hougaard copula: copula_gumbel()

Plackett copula: copula_plackett_bivar()

Student’s copula: copula_students_t()

initialize generator

multiple streams

leap-frog: init_leapfrog()

skip-ahead: init_skipahead()

skip-ahead (power of 2): init_skipahead_power2()

nonrepeatable sequence: init_nonrepeat()

repeatable sequence: init_repeat()

vector of variates from discrete univariate distributions

binomial distribution: int_binomial()

geometric distribution: int_geom()

hypergeometric distribution: int_hypergeom()

logarithmic distribution: int_log()

logical value or : logical()

negative binomial distribution: int_negbin()

Poisson distribution: int_poisson()

uniform distribution: int_uniform()

user-supplied distribution: int_general()

variate array from discrete distributions with array of parameters

Poisson distribution with varying mean: int_poisson_varmean()

vectors of variates from continuous univariate distributions

square distribution: dist_chisq()

beta distribution: dist_beta()

Cauchy distribution: dist_cauchy()

exponential mix distribution: dist_expmix()

-distribution: dist_f()

gamma distribution: dist_gamma()

logistic distribution: dist_logistic()

log-normal distribution: dist_lognormal()

negative exponential distribution: dist_exp()

Normal distribution: dist_normal()

real number from the continuous uniform distribution: dist_uniform01()

Student’s -distribution: dist_students_t()

triangular distribution: dist_triangular()

uniform distribution: dist_uniform()

von Mises distribution: dist_vonmises()

Weibull distribution: dist_weibull()

Quasi-random numbers

array of variates from univariate distributions

log-normal distribution: quasi_lognormal()

Normal distribution: quasi_normal()

uniform distribution: quasi_uniform()

generate

subset of dimensions

log-normal distribution: quasi_lognormal_bydim()

Normal distribution: quasi_normal_bydim()

uniform distribution: quasi_uniform_bydim()

initialize generator

scrambled Sobol or Niederreiter: quasi_init_scrambled()

Sobol, Niederreiter or Faure: quasi_init()

Random fields

one-dimensional

generation: field_1d_generate()

initialize generator

preset variogram: field_1d_predef_setup()

user-defined variogram: field_1d_user_setup()

two-dimensional

generation: field_2d_generate()

initialize generator

preset variogram: field_2d_predef_setup()

user-defined variogram: field_2d_user_setup()

For full information please refer to the NAG Library document

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g05/g05intro.html

Examples

naginterfaces.library.examples.rand.bb_inc_ex.main()[source]

Example for naginterfaces.library.rand.bb_inc().

Backs out increments from sample paths generated by a Brownian bridge algorithm.

>>> main()
naginterfaces.library.rand.bb_inc Python Example Results.
Compute numerical solutions to an SDE driven by a Wiener process.
Euler--Maruyama solution for Geometric Brownian motion:
         Path 1     Path 2     Path 3
  1      0.9668     1.0367     0.9992
  2      0.9717     1.0254     1.0077
  3      0.9954     1.0333     1.0098
  4      0.9486     1.0226     0.9911
  5      0.9270     1.0113     1.0630
  6      0.8997     1.0127     1.0164
  7      0.8955     1.0138     1.0771
  8      0.8953     0.9953     1.0691
  9      0.8489     1.0462     1.0484
 10      0.8449     1.0592     1.0429
 11      0.8158     1.0233     1.0625
 12      0.7997     1.0384     1.0729
 13      0.8025     1.0138     1.0725
 14      0.8187     1.0499     1.0554
 15      0.8270     1.0459     1.0529
 16      0.7914     1.0294     1.0783
 17      0.8076     1.0224     1.0943
 18      0.8208     1.0359     1.0773
 19      0.8190     1.0326     1.0857
 20      0.8217     1.0326     1.1095
 21      0.8084     0.9695     1.1389
Analytic solution at final time step:
         Path 1     Path 2     Path 3
         0.8079     0.9685     1.1389
naginterfaces.library.examples.rand.copula_students_t_ex.main()[source]

Example for naginterfaces.library.rand.copula_students_t().

Generates a matrix of pseudorandom numbers from a Student’s t copula.

>>> main()
naginterfaces.library.rand.copula_students_t Python Example Results.
Generate a matrix of pseudorandom numbers from a Student's t copula.
The copula values are
[
      0.6445,     0.0527,     0.4082,     0.8876
      0.0701,     0.1988,     0.8471,     0.3521
      0.7988,     0.6664,     0.2194,     0.5541
      0.8202,     0.0492,     0.7059,     0.9341
      0.1786,     0.5594,     0.7810,     0.2836
      0.4920,     0.2677,     0.3427,     0.5169
      0.4139,     0.2978,     0.8762,     0.7145
      0.7437,     0.9714,     0.8931,     0.2487
      0.4971,     0.9687,     0.8142,     0.1965
      0.6464,     0.5304,     0.5817,     0.4565
]