
Hi, I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds up `np.vander` by using accumulated multiplication instead of exponentiation to compute the Vandermonde matrix. For largish matrices the speed-ups can be quite dramatic, over an order of magnitude. Julian has raised concerns on numerical stability and loss of precision, which don't seem to be all that relevant. Do speak up if you think otherwise. We are also discussing replacing a recently added kwarg, "order", which now accepts a string, either "increasing" or "decreasing", to indicate the ordering of the matrix columns. This was not present in 1.8, so can still be modified. The proposal is to replace it with a "reversed" boolean flag. Unfortunately, the return of np.vander in 1.8 and before is the opposite (i.e. its reversed) from the standard definition, which has powers increasing from left to right. So it is not clear what the reversed keyword should refer to: 1. If it refers to the standard definition, then it would default to False for backwards compatibility, but be consistent with the conventional definition. 2. If it refers to the existing behavior of numpy's vander, then it would default to True, and not be consistent with the conventional definition. I prefer option 1, but would like to hear other's opinions. Which could of course include naming the boolean flag more ingeniously, or keeping the string flag. If he's reading, I'd specially like to hear Warren Weckesser's thoughts, as he is the one who added the "order" kwarg. Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.

On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
Hi,
I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds up `np.vander` by using accumulated multiplication instead of exponentiation to compute the Vandermonde matrix. For largish matrices the speed-ups can be quite dramatic, over an order of magnitude.
Julian has raised concerns on numerical stability and loss of precision, which don't seem to be all that relevant. Do speak up if you think otherwise.
We are also discussing replacing a recently added kwarg, "order", which now accepts a string, either "increasing" or "decreasing", to indicate the ordering of the matrix columns. This was not present in 1.8, so can still be modified. The proposal is to replace it with a "reversed" boolean flag. Unfortunately, the return of np.vander in 1.8 and before is the opposite (i.e. its reversed) from the standard definition, which has powers increasing from left to right. So it is not clear what the reversed keyword should refer to:
1. If it refers to the standard definition, then it would default to False for backwards compatibility, but be consistent with the conventional definition.
2. If it refers to the existing behavior of numpy's vander, then it would default to True, and not be consistent with the conventional definition.
I prefer option 1, but would like to hear other's opinions. Which could of course include naming the boolean flag more ingeniously, or keeping the string flag. If he's reading, I'd specially like to hear Warren Weckesser's thoughts, as he is the one who added the "order" kwarg.
"order" is not a good name, I would find it very confusing (I'm usually mixing up order and degree) http://en.wikipedia.org/wiki/Order_of_a_polynomial how about calling the keyword "increasing=False" ? which would avoid defining what it's reversed against. I don't know about precision loss. There's a nasty NIST problem for polynomial regression. If that doesn't change much, I wouldn't worry about differences in precision for statistical applications. But the problem is for the regression part, and might not be affected much by the vander precision. (Besides it's an example for "Don't do that at home.") http://jpktd.blogspot.ca/2012/03/numerical-accuracy-in-linear-least.html http://en.wikibooks.org/wiki/Statistics:Numerical_Methods/Numerical_Comparis... Josef
Jaime
-- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Sat, Mar 29, 2014 at 7:31 AM, <josef.pktd@gmail.com> wrote:
On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
Hi,
I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds up `np.vander` by using accumulated multiplication instead of exponentiation to compute the Vandermonde matrix. For largish matrices the speed-ups can be quite dramatic, over an order of magnitude.
Julian has raised concerns on numerical stability and loss of precision, which don't seem to be all that relevant. Do speak up if you think otherwise.
We are also discussing replacing a recently added kwarg, "order", which now accepts a string, either "increasing" or "decreasing", to indicate the ordering of the matrix columns. This was not present in 1.8, so can still be modified. The proposal is to replace it with a "reversed" boolean flag. Unfortunately, the return of np.vander in 1.8 and before is the opposite (i.e. its reversed) from the standard definition, which has powers increasing from left to right. So it is not clear what the reversed keyword should refer to:
1. If it refers to the standard definition, then it would default to False for backwards compatibility, but be consistent with the conventional definition.
2. If it refers to the existing behavior of numpy's vander, then it would default to True, and not be consistent with the conventional definition.
I prefer option 1, but would like to hear other's opinions. Which could of course include naming the boolean flag more ingeniously, or keeping the string flag. If he's reading, I'd specially like to hear Warren Weckesser's thoughts, as he is the one who added the "order" kwarg.
"order" is not a good name, I would find it very confusing (I'm usually mixing up order and degree) http://en.wikipedia.org/wiki/Order_of_a_polynomial
how about calling the keyword "increasing=False" ? which would avoid defining what it's reversed against.
Obviously I didn't read the PR before answering. But it shows that `increasing` might be obvious, or that Warren and I think the same way. Josef
I don't know about precision loss. There's a nasty NIST problem for polynomial regression. If that doesn't change much, I wouldn't worry about differences in precision for statistical applications.
But the problem is for the regression part, and might not be affected much by the vander precision. (Besides it's an example for "Don't do that at home.") http://jpktd.blogspot.ca/2012/03/numerical-accuracy-in-linear-least.html http://en.wikibooks.org/wiki/Statistics:Numerical_Methods/Numerical_Comparis...
Josef
Jaime
-- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion

On Sat, Mar 29, 2014 at 8:55 AM, <josef.pktd@gmail.com> wrote:
On Sat, Mar 29, 2014 at 7:31 AM, <josef.pktd@gmail.com> wrote:
On Sat, Mar 29, 2014 at 12:12 AM, Jaime Fernández del Río <jaime.frio@gmail.com> wrote:
Hi,
I have submitted a PR (https://github.com/numpy/numpy/pull/4568) that speeds up `np.vander` by using accumulated multiplication instead of exponentiation to compute the Vandermonde matrix. For largish matrices the speed-ups can be quite dramatic, over an order of magnitude.
Julian has raised concerns on numerical stability and loss of precision, which don't seem to be all that relevant. Do speak up if you think otherwise.
We are also discussing replacing a recently added kwarg, "order", which now accepts a string, either "increasing" or "decreasing", to indicate the ordering of the matrix columns. This was not present in 1.8, so can still be modified. The proposal is to replace it with a "reversed" boolean flag. Unfortunately, the return of np.vander in 1.8 and before is the opposite (i.e. its reversed) from the standard definition, which has powers increasing from left to right. So it is not clear what the reversed keyword should refer to:
1. If it refers to the standard definition, then it would default to False for backwards compatibility, but be consistent with the conventional definition.
2. If it refers to the existing behavior of numpy's vander, then it would default to True, and not be consistent with the conventional definition.
I prefer option 1, but would like to hear other's opinions. Which could of course include naming the boolean flag more ingeniously, or keeping the string flag. If he's reading, I'd specially like to hear Warren Weckesser's thoughts, as he is the one who added the "order" kwarg.
"order" is not a good name, I would find it very confusing (I'm usually mixing up order and degree) http://en.wikipedia.org/wiki/Order_of_a_polynomial
how about calling the keyword "increasing=False" ? which would avoid defining what it's reversed against.
Obviously I didn't read the PR before answering.
But it shows that `increasing` might be obvious, or that Warren and I think the same way.
Great minds think alike! It seems we have a 4 people consensus, "increasing" it is. Thanks for the feedback. Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
participants (2)
-
Jaime Fernández del Río
-
josef.pktd@gmail.com