numpy.vander() function is used to generate a Vandermonde matrix.
Syntax : numpy.vander(arr, N = None, increasing = False)
Parameters :
arr : [ array_like] 1-D input array.
N : [int, optional] Number of columns in the output. If N is not specified, a square array is returned (N = len(x)).
increasing : [bool, optional] Order of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.
Return : [ndarray] dVandermonde matrix. If increasing is False, the first column is x^(N-1), the second x^(N-2) and so forth. If increasing is True, the columns are x^0, x^1, …, x^(N-1).
Code #1 :
# Python program explaining # numpy.vander() function # importing numpy as geek import numpy as geek arr = geek.array([1, 2, 3, 4, 5]) gfg = geek.vander(arr) print (gfg) |
Output :
[[ 1 1 1 1 1] [ 16 8 4 2 1] [ 81 27 9 3 1] [256 64 16 4 1] [625 125 25 5 1]]
Code #2 :
# Python program explaining # numpy.vander() function # importing numpy as geek import numpy as geek arr = geek.array([1, 2, 3, 4, 5]) N = 3 gfg = geek.vander(arr, N) print (gfg) |
Output :
[[ 1 1 1] [ 4 2 1] [ 9 3 1] [16 4 1] [25 5 1]]
Code #3 :
# Python program explaining # numpy.vander() function # importing numpy as geek import numpy as geek arr = geek.array([1, 2, 3, 4, 5]) gfg = geek.vander(arr, increasing = True) print (gfg) |
Output :
[[ 1 1 1 1 1] [ 1 2 4 8 16] [ 1 3 9 27 81] [ 1 4 16 64 256] [ 1 5 25 125 625]]
Recommended Posts:
- Numpy MaskedArray.atleast_3d() function | Python
- Numpy MaskedArray.atleast_1d() function | Python
- Numpy MaskedArray.atleast_2d() function | Python
- Python | Numpy nanmedian() function
- Python | numpy.issctype() function
- Python | numpy.issubsctype() function
- Python | numpy.issubdtype() function
- Python | numpy.nanmean() function
- Python | numpy.cov() function
- Python | numpy.copyto() function
- Numpy recarray.any() function | Python
- Numpy recarray.all() function | Python
- Numpy recarray.argmax() function | Python
- Numpy recarray.argmin() function | Python
- Numpy recarray.argpartition() function | Python
- Numpy recarray.byteswap() function | Python
- Numpy recarray.argsort() function | Python
- Numpy recarray.clip() function | Python
- Numpy recarray.compress() function | Python
- Numpy MaskedArray.all() function | Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

