numpy.polynomial.laguerre.lagvander#

polynomial.laguerre.lagvander(x, deg)[源代码]#

给定阶数的伪范德蒙矩阵.

返回阶数为 deg 和采样点 x 的伪范德蒙矩阵.伪范德蒙矩阵定义为

\[V[..., i] = L_i(x)\]

其中 0 <= i <= deg . V 的前导索引是对 x 的元素进行索引,最后一个索引是拉盖尔多项式的阶数.

如果 c 是长度为 n + 1 的系数的一维数组,而 V 是数组 V = lagvander(x, n) ,那么 np.dot(V, c)lagval(x, c) 在舍入误差范围内是相同的.这种等价性对于最小二乘拟合以及对相同阶数和样本点的多个拉盖尔级数进行求值都很有用.

参数:
xarray_like

点数组.dtype 被转换为 float64 或 complex128,具体取决于是否有任何元素是复数. 如果 x 是标量,则将其转换为 1-D 数组.

degint

结果矩阵的阶数.

返回:
vanderndarray

伪 Vandermonde 矩阵.返回的矩阵的形状为 x.shape + (deg + 1,) ,其中最后一个索引是相应拉盖尔多项式的阶数.dtype 将与转换后的 x 相同.

示例

>>> import numpy as np
>>> from numpy.polynomial.laguerre import lagvander
>>> x = np.array([0, 1, 2])
>>> lagvander(x, 3)
array([[ 1.        ,  1.        ,  1.        ,  1.        ],
       [ 1.        ,  0.        , -0.5       , -0.66666667],
       [ 1.        , -1.        , -1.        , -0.33333333]])