📜  python代码示例中的R sample()函数

📅  最后修改于: 2022-03-11 14:45:08.374000             🧑  作者: Mango

代码示例1
import numpy as np
np.random.choice(values, size=1000,  replace=True, p=probability)

# values is the input values that correspond to the weights
# size is the number of samples to generate
# Replace specifies if it's with or without replacement
# p is the probability of choosing each corresponding value in values