numpy.polynomial.hermite.hermvander#
- polynomial.hermite.hermvander(x, deg)[源代码]#
给定次数的伪范德蒙矩阵。
返回次数为 deg、样本点为 x 的伪范德蒙矩阵。伪范德蒙矩阵定义为
\[V[..., i] = H_i(x),\]其中
0 <= i <= deg
。 V 的前导索引是 x 的元素索引,最后一个索引是埃尔米特多项式的次数。如果 c 是一个长度为
n + 1
的一维系数数组,且 V 是数组V = hermvander(x, n)
,那么np.dot(V, c)
和hermval(x, c)
在舍入误差范围内是相同的。这种等价性对于最小二乘拟合以及评估大量相同次数和样本点的埃尔米特级数都很有用。- 参数:
- xarray_like
点数组。根据是否有任何元素是复数,其 dtype 会转换为 float64 或 complex128。如果 x 是标量,则会转换为一维数组。
- degint
结果矩阵的次数。
- 返回:
- vanderndarray
伪范德蒙矩阵。返回矩阵的形状为
x.shape + (deg + 1,)
,其中最后一个索引是对应埃尔米特多项式的次数。dtype 将与转换后的 x 相同。
示例
>>> import numpy as np >>> from numpy.polynomial.hermite import hermvander >>> x = np.array([-1, 0, 1]) >>> hermvander(x, 3) array([[ 1., -2., 2., 4.], [ 1., 0., -2., -0.], [ 1., 2., 2., -4.]])