有一个程序需要从分布在[1, 500]. 如何从输出中获取随机样本?
我写了以下内容:
N = 1000
x = 1 + 500 * np.random.rand(N)
sp_x = random.sample(x, 100)
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
TypeError: Population must be a sequence or set. For dicts, use list(d).
Run Code Online (Sandbox Code Playgroud)