$$ P(\varepsilon) = \frac{1}{4k} \mathrm{sech}^2 \frac{\varepsilon}{2k}$$
$$ CDF(\varepsilon) = \frac{\tanh(\frac{\varepsilon}{2k})}{2} $$
$$ CDF^{-1}(c) = \frac{c}{2\tanh^{-1}(2k_BT)} $$
Now what should I do to generate N samples, with my PDF P(\varepsilon) of given k?
Here is what I have so far:
import numpy as np
def sampleConduction(N, kT):
for i in range(N):
c = np.random.random()
list = [c]
print('list=',list)
g = np.column_stack(list)
print('g=',g)
d = np.arctanh(2*list)+2*kT
return d
sampleConduction(3,0.1)
The result of this code is:
list= [0.7687170402304889]
list= [0.24759083266582882]
list= [0.18334770166799108]
g= [[0.1833477]]
array([0.38544466, 0.38544466]) # d
I wanted to combine the 3 lists into one, but failed by using np.column_stack(). What should I try next?
Thanks a lot!