I have a complicated (non standard) distribution function that I want to sample to generate simulated data points using the inverse cdf technique. For the sake of this example I will consider a Gaussian distribution
var=100
def f(x,a):
def g(y):
return (1/np.sqrt(2*np.pi*var))*np.exp(-y**2/(2*var))
b,err=integrate.quad(g,-np.inf,x)
return b-a
I want to generate values between a=[0,1]
, a=np.linspace(0,1,10000,endpoint=False)
and use scipy.optimize.fsolve
to solve for x for each a
.
I have two questions:
How to use
fsolve
for an array of valuesa
?fsolve
takes an initial guessx0
, how to pick a good guess value?
Thanks