#!/usr/bin/env python3
"``naginterface.library.rand.copula_students_t`` Python Example."
# NAG Copyright 2019.
# pylint: disable=invalid-name
from naginterfaces.library import rand
[docs]def main():
"""
Example for :func:`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
]
"""
print(
'naginterfaces.library.rand.copula_students_t Python Example Results.'
)
print(
'Generate a matrix of pseudorandom numbers from a Student\'s t copula.'
)
# Create a state structure for a repeatable sequence,
# using the NAG basic generator (genid=1):
statecomm = rand.init_repeat(
genid=1, subid=1, seed=[1762543],
)
# The sample size:
n = 10
# The degrees of freedom:
df = 10
# The covariance matrix:
c = [
[1.69, 0.39, -1.86, 0.07],
[0., 98.01, -7.07, -0.71],
[0., 0., 11.56, 0.03],
[0., 0., 0., 0.01],
]
# An empty communication structure for the reference vector
# in the copula function:
comm = {}
# Make a combined set-up/generate call to the copula
# function (mode=2):
mode = 2
x = rand.copula_students_t(mode, n, df, c, comm, statecomm)
print('The copula values are')
print('[')
for i in range(x.shape[0]):
print(
' ' +
', '.join(['{:10.4f}']*x.shape[1]).format(*x[i, :])
)
print(']')
if __name__ == '__main__':
import doctest
import sys
sys.exit(
doctest.testmod(
None, verbose=True, report=False,
optionflags=doctest.REPORT_NDIFF,
).failed
)