生成对称i.i.d分布随机数(Python)

时间:2022-10-16 11:40:50

I'm trying to generate an matrix drawn from a symmetric i.i.d distribution over integers from the range (0,3) (Integers 0 to 3 having the same probability of being drawn (1/4)). I looked at different numpy.random sampling but I'm not sure which one is appropriate.

我正在尝试从范围(0,3)的整数生成从对称i.i.d分布绘制的矩阵(整数0到3具有相同的绘制概率(1/4))。我看了不同的numpy.random采样,但我不确定哪一个是合适的。

Any suggestions on sampling identically distributed integers?

关于对同分布整数进行采样的任何建议?

1 个解决方案

#1


1  

import numpy as np

m = np.random.randint(low=0,high=4,size=(4,4))

note the the first number is inclusive, and the second is exclusive, and the last gives the dimensions:

请注意第一个数字是包含的,第二个是独占的,最后一个是维度:

In [35] m
Out[35]: 

array([[0, 3, 2, 3],
       [0, 3, 0, 0],
       [0, 2, 3, 1],
       [2, 3, 0, 3]])

note the the first number is inclusive, and the second is exclusive, and the last gives the dimensions.

请注意第一个数字是包含的,第二个是独占的,最后一个是维度。

#1


1  

import numpy as np

m = np.random.randint(low=0,high=4,size=(4,4))

note the the first number is inclusive, and the second is exclusive, and the last gives the dimensions:

请注意第一个数字是包含的,第二个是独占的,最后一个是维度:

In [35] m
Out[35]: 

array([[0, 3, 2, 3],
       [0, 3, 0, 0],
       [0, 2, 3, 1],
       [2, 3, 0, 3]])

note the the first number is inclusive, and the second is exclusive, and the last gives the dimensions.

请注意第一个数字是包含的,第二个是独占的,最后一个是维度。