Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
numpy
python
communitycreator

What is the numpy.vander() function from NumPy in Python?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The vander() function in Python is simply used to generate a Vandermonde matrix.

Syntax

numpy.vander(x, N=None, increasing=False)

Parameter value

The vander() function takes the following parameter values.

  • x: This represents the 1-D input array.
  • N: This represents the number of columns in the output matrix or array.
  • increasing: This takes a Boolean value and represents the power of the columns. If True, the powers increase from left to right, if False by default, they are reversed.

Return values

The vander() function returns a Vandermonde matrix.

Code example

import numpy as np
# creating an array
myarray = np.array([1, 2, 3, 4, 5])
# implementing the vander() function
mymatrix = np.vander(myarray, N=3, increasing=False)
print(mymatrix)
Implementing the vander() function

Explanation

  • Line 1: We import the numpy module.
  • Line 4: We create an array, myarray, having 5 elements.
  • Line 7: We implement the vander() function on the array myarray using 3, as the number of columns of the output array and a default value for the increasing parameter. The output is assigned to a new variable, mymatrix.
  • Line 9: We print the Vandermonde matrix mymatrix.

RELATED TAGS

function
numpy
python
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring