0

Okay, so I have this two part 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)

and I've done this to find the empirical CDF

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

but I don't know how to generate 10000 random samples from my CDF (such samples would be put into sampleH1)

currently, I'm doing this but I don't think it's right

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

Where sampleH0 is 10000 samples from a normally distributed CDF

If anyone could shed some light that'd be great thanks

Paul H
  • 65,268
  • 20
  • 159
  • 136
Tyler Angelo
  • 105
  • 1
  • 1
  • 7

1 Answers1

0

If you're using numpy, you can just ditch the loop:

sampleH1 = sampleH0 + cdfH1a(sampleH0) + cdfH1b(sampleH0)

Paul H
  • 65,268
  • 20
  • 159
  • 136