normal2#

nvmath.device.random.normal2(state)#

使用指定的位生成器状态,从正态分布中采样两个浮点数。

参数:

state – 对应于其中一个位生成器的状态对象。

返回值:

类型为 nvmath.device.float32x2 的值。

示例

以下内核的 states 参数应为已初始化的位生成器状态数组。有关如何创建和初始化位生成器状态的更多详细信息,请参阅 nvmath.device.random.init() 的文档。

>>> from numba import cuda
>>> from nvmath.device import random
>>> compiled_apis = random.Compile()
>>> @cuda.jit(link=compiled_apis.files, extensions=compiled_apis.extension)
... def kernel(states):
...     i = cuda.grid(1)
...     value = random.normal2(states[i])