user user - 4 years ago 95
Python Question

Is there a function in numpy where it will return a matrix of each row of vector raised from a power of 0 to integer

Suppose I have a vertical vector X = [1,[2],[3]] and integer pow = 2.
Is there a function in numpy where it will return a matrix of each row of vector x raised from a power of 0 to pow (pow = 2)

The above example should return a matrix

[[1, 1, 1],
[1, 2, 4],
[1, 3, 9]]


I looked at numpy.power, however returns an array.

Answer Source

The function you are looking for is

numpy.vander

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download