Last updated: 2023-03-16.
tf_quant_finance.math.qmc.digital_net_sample#
Constructs a digital net from a generating matrix.
tf_quant_finance.math.qmc.digital_net_sample(
generating_matrices, num_results, num_digits, sequence_indices=None,
scrambling_matrices=None, digital_shift=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 2D Sobol generating matrices.
dim = 2
num_results = 1000
num_digits = 10
tff.math.qmc.digital_net_sample(
tff.math.qmc.sobol_generating_matrices(dim, num_results, num_digits),
num_results,
num_digits)
# ==> 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:#
generating_matrices: Positive scalarTensorof integers with rank 2. The matrix from which to sample points.num_results: Positive scalarTensorof integers with rank 0. The maximum number of points to sample fromgenerating_matrices.num_digits: Positive scalarTensorof integers with rank 0. the base-2 precision of the points sampled fromgenerating_matrices.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.scrambling_matrices: Optional positive scalarTensorof integers with the same shape asgenerating_matrices. The left matrix scramble to apply to the generating matrices. Default value:None.digital_shift: Optional positive scalarTensorof integers with shape (dim) wheredim = tf.shape(generating_matrices)[0]. The digital shift to apply to all the sampled points via a bitwise xor. 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 tosample_digital_net.
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].