[SciPy-User] multidimensional polynomial fit
David Goldsmith
d.l.goldsmith@gmail....
Sun Jun 13 14:42:24 CDT 2010
On Sat, Jun 12, 2010 at 10:28 PM, Oscar Gerardo Lazo Arjona <
algebraicamente@gmail.com> wrote:
> <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
> with
> 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).
DG
>
> > 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 ;)
>
> thanks.
>
> Oscar
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>
--
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...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100613/2ffacf27/attachment.html
More information about the SciPy-User
mailing list