tf_quant_finance.math.random.sobol.sample

Last updated: 2023-03-16.

tf_quant_finance.math.random.sobol.sample#

View source

Returns num_results samples from the Sobol sequence of dimension dim.

tf_quant_finance.math.random.sobol.sample(
    dim, num_results, skip=0, validate_args=False, dtype=None, name=None
)

Uses the original ordering of points, not the more commonly used Gray code ordering. Derived from notes by Joe & Kuo[1].

[1] describes bitwise operations on binary floats. The implementation below achieves this by transforming the floats into ints, being careful to align the digits so the bitwise operations are correct, then transforming back to floats.

Args:#

  • dim: Positive Python int representing each sample’s event_size.

  • num_results: Positive scalar Tensor of dtype int32. The number of Sobol points to return in the output.

  • skip: Positive scalar Tensor of dtype int32. The number of initial points of the Sobol sequence to skip.

  • validate_args: Python bool. When True, input Tensor's are checked for validity despite possibly degrading runtime performance. The checks verify that dim >= 1, num_results >= 1, skip >= 0 and whether num_results + skip < 2**31 - 1. When False invalid inputs may silently render incorrect outputs. Default value: False.

  • dtype: Optional dtype. The dtype of the output Tensor (either float32 or float64). Default value: None which maps to the float32.

  • name: Python str name prefixed to ops created by this function.

Returns:#

Tensor of samples from Sobol sequence with shape [n, dim].

References#

[1]: S. Joe and F. Y. Kuo. Notes on generating Sobol sequences. August 2008. https://web.maths.unsw.edu.au/~fkuo/sobol/joe-kuo-notes.pdf