random_tensor_from_values#

sionna.phy.utils.random_tensor_from_values(values: torch.Tensor | List[Any], shape: List[int] | torch.Size, dtype: torch.dtype | None = None) torch.Tensor[source]#

Generates a tensor of the specified shape, with elements randomly sampled from the provided set of values.

Parameters:
Outputs:

tensor – A tensor with the specified shape, where each element is randomly selected from values

Examples

from sionna.phy.utils import random_tensor_from_values

values = [0, 10, 20]
shape = [2, 3]
print(random_tensor_from_values(values, shape).numpy())
# array([[ 0, 20,  0],
#        [10,  0, 20]], dtype=int32)