tf_quant_finance.math.qmc.sobol_generating_matrices

Last updated: 2023-03-16.

tf_quant_finance.math.qmc.sobol_generating_matrices#

View source

Returns Sobol generating matrices.

tf_quant_finance.math.qmc.sobol_generating_matrices(
    dim, num_results, num_digits, validate_args=False, dtype=None, name=None
)

Examples#

import tf_quant_finance as tff

# Example: Creating the 4D Sobol generating matrices.

dim = 4
num_results = 500
num_digits = 9

tff.math.qmc.sobol_generating_matrices(dim, num_results, num_digits)
# ==> tf.Tensor([
#             [256, 128,  64,  32,  16,   8,   4,   2,   1],
#             [256, 384, 320, 480, 272, 408, 340, 510, 257],
#             [256, 384, 192, 288, 464, 184, 284, 394, 209],
#             [256, 384,  64, 160, 496, 232, 324, 294, 433],
#         ], shape=(4, 9), dtype=int32)

Args:#

  • dim: Positive scalar Tensor of integers with rank 0. The event size of points which can be sampled from the resulting generating matrices.

  • num_results: Positive scalar Tensor of integers with rank 0. The maximum number of points which can be sampled from the resulting generating matrices.

  • num_digits: Positive scalar Tensor of integers with rank 0. The base-2 precision of points which can be sampled from the resulting generating matrices.

  • validate_args: Python bool indicating whether to validate arguments. Default value: False.

  • dtype: Optional dtype. The dtype of the output Tensor (either a signed or unsigned integer dtype). Default value: None which maps to int32.

  • name: Python str name prefixed to ops created by this function. Default value: None which maps to sobol_generating_matrices.

Returns:#

A scalar Tensor with shape (dim, log_num_results) where log_num_results = ceil(log2(num_results)).