numpy.ma.vander

numpy.ma.vander(x, n=None)

Generate a Van der Monde matrix.

The columns of the output matrix are decreasing powers of the input vector. Specifically, the i-th output column is the input vector to the power of N - i - 1.

Parameters:

x : array_like

Input array.

N : int, optional

Order of (number of columns in) the output.

Returns:

out : ndarray

Van der Monde matrix of order N. The first column is x^(N-1), the second x^(N-2) and so forth.

Notes

Masked values in the input array result in rows of zeros.

Examples

>>> x = np.array([1, 2, 3, 5])
>>> N = 3
>>> np.vander(x, N)
array([[ 1,  1,  1],
       [ 4,  2,  1],
       [ 9,  3,  1],
       [25,  5,  1]])
>>> np.column_stack([x**(N-1-i) for i in range(N)])
array([[ 1,  1,  1],
       [ 4,  2,  1],
       [ 9,  3,  1],
       [25,  5,  1]])

Previous topic

numpy.ma.MaskedArray.transpose

Next topic

numpy.ma.polyfit

This Page

Quick search