[SciPy-User] multidimensional polynomial fit
Sun Jun 13 14:42:24 CDT 2010
On Sat, Jun 12, 2010 at 10:28 PM, Oscar Gerardo Lazo Arjona <
> <josef.pktd <at> gmail.com> writes:
> > Assuming I understand correctly, fitting the last variable to a
> > polynomial of the first three
> > depends on how many cross terms you want.
> Well, I already wrote a generalized function that works like polyfit:
> def polynomial_fit(points,degree,depreciation=False):
> It returns an array of the coefficients of the multidimensional polynomial
> the degrees indicated as a list of integers (just as polyfit).
> It was quite a lot of work, it's probably the most abstract thing I've
> done. I
> had lot's of fun writing it, and I would like it to be included in numpy
> (if you
> think that is wise).
Whatever you do, before submission, please ensure that your function has a
complete, Standard-conforming docstring (and, though this is not "my
department," so to speak, most would probably join me in also asking that it
be accompanied by a pretty complete suite of unit tests, esp. something as
mathematically complicated as this - my off-the-cuff would be that it should
have at least three, preferably at least five non-trivial or semi-trivial
tests, by which I mean tests which pass when a non-trivial solution
consisting of simple, e.g., integer, values is produced exactly [to within,
say, 9 sigfigs], for at least two degrees above 2, one even and one odd -
just my $0.02).
> > here is an example which restricts the powers in the cross-terms
> > >>> x = np.arange(5)[:,None]+ [0,10,100]
> > use of OLS can be replaced by np.linalg.lstsq
> Well, thank you, but that's a lot more complicated to remember ;)
> SciPy-User mailing list
Mathematician: noun, someone who disavows certainty when their uncertainty
set is non-empty, even if that set has measure zero.
Hope: noun, that delusive spirit which escaped Pandora's jar and, with her
lies, prevents mankind from committing a general suicide. (As interpreted
by Robert Graves)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User