Last updated: 2023-03-16.
tf_quant_finance.math.qmc.sobol_sample#
Samples points from the Sobol sequence.
tf_quant_finance.math.qmc.sobol_sample(
dim, num_results, sequence_indices=None, digital_shift=None,
scrambling_matrices=None, apply_tent_transform=False, validate_args=False,
dtype=None, name=None
)
Examples#
import tf_quant_finance as tff
# Example: Sampling 1,000 points from the 2D Sobol sequence.
dim = 2
num_results = 1000
tff.math.qmc.sobol_sample(dim, num_results)
# ==> tf.Tensor([
# [0., 0. ],
# [0.5, 0.5 ],
# [0.25, 0.75 ],
# ...
# [0.65527344, 0.9736328 ],
# [0.40527344, 0.7236328 ],
# [0.90527344, 0.22363281],
# ], shape=(1000, 2), dtype=float32)
Args:#
dim: Positive scalarTensorof integers with rank 0. The event size of the sampled points.num_results: Positive scalarTensorof integers with rank 0. The number of points to sample.sequence_indices: Optional positive scalarTensorof integers with rank 1. The elements of the sequence to return specified by their position in the sequence. Default value:Nonewhich corresponds to the[0, num_results)range.digital_shift: Optional digital shift to be applied to all the points via a bitwise xor. Default value:None.scrambling_matrices: Positive scalarTensorwith the sameshapeanddtypeasgenerating_matrices. Used to randomizegenerating_matrices. Default value:None.apply_tent_transform: Pythonboolindicating whether to apply a tent transform to the sampled points. Default value:False.validate_args: Pythonboolindicating whether to validate arguments. Default value:False.dtype: Optionaldtype. Thedtypeof the outputTensor(eitherfloat32orfloat64). Default value:Nonewhich maps tofloat32.name: Pythonstrname prefixed to ops created by this function. Default value:Nonewhich maps tosobol_sample.
Returns:#
A Tensor of samples from the Sobol sequence with shape
(num_samples, dim) where num_samples = min(num_results, size(sequence_indices)) and dim = tf.shape(generating_matrices)[0].