给定分布的随机抽样

2024-09-27 18:22:11 发布

您现在位置:Python中文网/ 问答频道 /正文

好的,我有两部分CDF

def cdfH1a(x):
    return 0.189497583190681*np.sqrt(2 * np.pi)*sp.erf(np.sqrt(2)* (x/2))
def cdfH1b(x):
    return 0.0141047395886939*np.sqrt(np.pi)*sp.erf(7.07106781186547*x - 14.1421356237309)

我这样做是为了找到经验CDF

sorted = np.sort(sampleH1)
yVals = np.arange(len(sorted))/float(len(sorted))
plt.plot(sorted, yVals)
plt.show()

但是我不知道如何从我的CDF中生成10000个随机样本(这样的样本会放入sampleH1)

目前,我正在这样做,但我不认为这是正确的

sampleH1 = []
for x in sampleH0: 
    sampleH1.append(x + (cdfH1a(x) + cdfH1b(x)))

其中,sampleH0是来自正态分布CDF的10000个样本

如果有人能透露一些信息那就太好了谢谢


Tags: lenreturndefnppipltsqrtsp

热门问题