Thx Seb!
2011/12/14 Benjamin Root <ben...@ou...>:
>
>
> On Wednesday, December 14, 2011, Fabien Lafont <laf...@gm...>
> wrote:
>> I have a basic problem (I think)
>>
>> I try to fit some data with this function
>>
>> http://docs.scipy.org/doc/numpy/reference/generated/numpy.polynomial.Chebyshev.fit.html
>>
>> But it return an error:
>>
>> fit = chebyshev.fit(T,R,3)
>> NameError: name 'chebyshev' is not defined
>>
>> I don't understand I've imported Numpy and polynomials... An Idea?
>>
>>
>> import math
>> from numpy import *
>> from numpy import polynomial
>> from pylab import *
>> from scipy import *
>> from scipy import optimize
>> import warnings
>> warnings.simplefilter('ignore', np.RankWarning)
>>
>>
>> R = [ 9011.5 , 7822.7 , 6253.9 , 4877.56 , 3892.08 ,
>> 3221.41 , 2647.05,
>> 2260.94 , 1959.72 , 1712.06 , 1522.28 , 1367.87 , 1242.953
>> , 1185.092,
>> 1104.452 , 1031.862 , 919.8644 , 832.9942 , 767.8944 , 715.1569,
>> 671.6301 , 635.1634 , 604.284 , 577.5536]
>>
>> T = range(0,len(R))
>> plot (T,R,".")
>> show()
>> fit = chebyshev.fit(T,R,3)
>> print fit
>>
>
> The function would be in the "polynomial" namespace. So
> "polynomial.chebyshev()" would work. To reduce typing, you can import a
> module "as" some other name.
>
> from numpy import polynomial as poly
>
> ..
>
> fit = poly.chebyshev.fit(T,R,3)
>
> Importing modules is very flexible and I suggest reading up on it.
>
> Ben Root
|