我有一个9个元素的数组。 我随机抽取4个元素,每个元素重复3次
但我还想重复两次(在其他数组中)未采样的数字
例如:
是=[0,0,0,4,4,4,1,1,8,8]
我需要:
否=[1,1,2,2,3,3,5,5,6,6,7,9]
我该怎么做
allStims = [0, 1, 2, 3, 4, 5, 6, 7, 8]
##Pick randomly 4 numbers and repeat each 3 times
yeses = np.repeat(random.sample(allStims, 4),3)
print(yeses)
您可以使用列表理解来获取原始列表中不在
yeses
中的所有值相关问题 更多 >
编程相关推荐