pfhedge.stochastic.randn_sobol_boxmuller¶
- pfhedge.stochastic.randn_sobol_boxmuller(*size, dtype=None, device=None, scramble=True, seed=None)[source]¶
Returns a tensor filled with random numbers obtained by a Sobol sequence applied with the Box-Muller transformation.
The outputs should be normal distribution with mean 0 and variance 1 (also called the standard normal distribution).
- Parameters
size (
int
…) – a sequence of integers defining the shape of the output tensor. Can be a variable number of arguments or a collection like a list or tuple.dtype (torch.dtype, optional) – The desired data type of returned tensor. Default: If
None
, uses a global default (seetorch.set_default_tensor_type()
).device (torch.device, optional) – The desired device of returned tensor. Default: If
None
, uses the current device for the default tensor type (seetorch.set_default_tensor_type()
).device
will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
- Returns
torch.Tensor
Examples
>>> from pfhedge.stochastic import randn_sobol_boxmuller >>> >>> _ = torch.manual_seed(42) >>> output = randn_sobol_boxmuller(4, 3) >>> output tensor([[ 0.0559, 0.4954, -0.8578], [-0.7492, -1.0370, -0.4778], [ 0.1651, 0.0430, -2.0368], [ 1.1309, -0.1779, 0.0796]])