Siegfried Gonzi
2016-08-02 17:41:21 UTC
Hi all
Does anyone know how to invoke curve_fit with a variable number of parameters, e.g. a1 to a10 without writing it out,
e.g.
def func2( x, a1,a2,a3,a4 ):
# Bessel function
tmp = scipy.special.j0( x[:,:] )
return np.dot( tmp[:,:] , np.array( [a1,a2,a3,a4] )
### yi = M measurements (.e.g M=20)
### x = M (=20) rows of N (=4) columns
popt = scipy.optimize.curve_fit( func2, x, yi )
I'd like to get *1 single vector* (in this case of size 4) of optimised A(i) values.
The function I am trying to minimise (.e.g F(r) is a vector of 20 model measurements): F(r) = SUM_i_to_N [ A(i) * bessel_function_J0(i * r) ]
Thanks,
Siegfried Gonzi
Does anyone know how to invoke curve_fit with a variable number of parameters, e.g. a1 to a10 without writing it out,
e.g.
def func2( x, a1,a2,a3,a4 ):
# Bessel function
tmp = scipy.special.j0( x[:,:] )
return np.dot( tmp[:,:] , np.array( [a1,a2,a3,a4] )
### yi = M measurements (.e.g M=20)
### x = M (=20) rows of N (=4) columns
popt = scipy.optimize.curve_fit( func2, x, yi )
I'd like to get *1 single vector* (in this case of size 4) of optimised A(i) values.
The function I am trying to minimise (.e.g F(r) is a vector of 20 model measurements): F(r) = SUM_i_to_N [ A(i) * bessel_function_J0(i * r) ]
Thanks,
Siegfried Gonzi
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.