[Numpy-discussion] Polynomial evaluation inconsistencies
ilhanpolat at gmail.com
Sat Jun 30 15:08:17 EDT 2018
I think restricting polynomials to time series is not a generic way and
Apart from the series and certain filter design actual usage of polynomials
are always presented with decreasing order (control and signal processing
included because they use powers of s and inverse powers of z if needed).
So if that is the use case then probably it should go under a namespace of
`TimeSeries` or at least require an option to present it in reverse. In my
opinion polynomials are way more general than that domain and to everyone
else it seems to me that "the intuitive way" is the decreasing powers.
For the design
> This isn't a great design, because they represent:
> p(x) = c * x^2 + c * x^1 + c * x^0
I don't see the problem actually. If I ask someone to write down the
coefficients of a polynomial I don't think anyone would start from c.
On Sat, Jun 30, 2018 at 8:30 PM, Charles R Harris <charlesr.harris at gmail.com
> On Sat, Jun 30, 2018 at 12:09 PM, Eric Wieser <wieser.eric+numpy at gmail.com
> > wrote:
>> > if a single program uses both np.polyval() and
>> np.polynomail.Polynomial, it seems bound to cause unnecessary confusion.
>> Yes, I would recommend definitely not doing that!
>> > I still think it would make more sense for np.polyval() to use
>> conventional indexing
>> Unfortunately, it's too late for "making sense" to factor into the
>> design. `polyval` is being used in the wild, so we're stuck with it
>> behaving the way it does. At best, we can deprecate it and start telling
>> people to move from `np.polyval` over to `np.polynomial.polynomial.polyval`.
>> Perhaps we need to make this namespace less cumbersome in order for that to
>> be a reasonable option.
>> I also wonder if we want a more lightweight polynomial object without the
>> extra domain and range information, which seem like they make `Polynomial`
>> a more questionable drop-in replacement for `poly1d`.
> The defaults for domain and window make it like a regular polynomial. For
> fitting, it does adjust the range, but the usual form can be recovered with
> `p.convert()` and will usually have more accurate coefficients due to using
> a better conditioned matrix during the fit.
> In : from numpy.polynomial import Polynomial as P
> In : p = P([1, 2, 3], domain=(0,2))
> In : p(0)
> Out: 2.0
> In : p.convert()
> Out: Polynomial([ 2., -4., 3.], domain=[-1., 1.], window=[-1., 1.])
> In : p.convert()(0)
> Out: 2.0
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion