polynomial.hermite.
hermfit
埃尔米特级数与数据的最小二乘拟合。
返回厄米级数的系数 deg 这是符合数据值的最小二乘法 y 给定点 x .如果 y 是1-d,返回系数也将是1-d。如果 y 是否进行了二维多次拟合,每列一次 y ,生成的系数存储在二维返回的相应列中。拟合多项式的形式为
System Message: WARNING/2 (P(x)=C_0+C_1 * H_1(x) + ... + c_n * Hyn(x),)
latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...(x) + ... + c_n * Hyn(x),\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 512 bytes). Transcript written on math.log.
在哪里? n 是 deg .
m采样点的x坐标 (x[i], y[i]) .
(x[i], y[i])
采样点的Y坐标。通过传递一个每列包含一个数据集的二维数组,可以同时拟合多个共享相同X坐标的采样点数据集。
拟合多项式的度数。如果 deg 是一个整数,所有项都小于或等于 deg “这一术语包含在拟合中。对于numpy版本>=1.11.0,可以使用指定要包含项的度数的整数列表。
拟合的相对条件数。相对于最大奇异值,小于此值的奇异值将被忽略。默认值是len(x)*eps,其中eps是浮点类型的相对精度,在大多数情况下约为2e-16。
开关决定返回值的性质。当它为假(默认值)时,仅返回系数,当同时返回奇异值分解的真实诊断信息时。
砝码。如果不是没有,每个点的贡献 (x[i],y[i]) 拟合的权重为 w[i] . 理想情况下,选择权重是为了使产品的误差 w[i]*y[i] 都有相同的差异。默认值为无。
(x[i],y[i])
w[i]*y[i]
厄米系数由低到高排列。如果 y 为2-d,第k列数据的系数 y 列中 k .
只有当 full =真
resid——最小二乘拟合秩的平方残差之和——标度范德蒙矩阵Sv的数值秩——标度范德蒙矩阵Rcond的奇异值——标度范德蒙矩阵Rcond的值。 rcond .
有关详细信息,请参阅 numpy.linalg.lstsq .
numpy.linalg.lstsq
最小二乘拟合中系数矩阵的秩是不足的。只有在以下情况下才会发出警告: full =假。可通过以下方式关闭警告:
>>> import warnings >>> warnings.simplefilter('ignore', np.RankWarning)
参见
numpy.polynomial.chebyshev.chebfit
numpy.polynomial.legendre.legfit
numpy.polynomial.laguerre.lagfit
numpy.polynomial.polynomial.polyfit
numpy.polynomial.hermite_e.hermefit
hermval
计算Hermite序列。
hermvander
赫米特系列的范德蒙矩阵。
hermweight
厄米重函数
从矩阵计算最小二乘拟合。
scipy.interpolate.UnivariateSpline
计算样条曲线拟合。
笔记
解是厄米特级数的系数。 p 使加权平方误差之和最小化
System Message: WARNING/2 (E=\sum j w_j^2*y_j-p(x_j)^2,)
latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} ! Package inputenc Error: Unicode character , (U+FF0C) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 ...sum j w_j^2*y_j-p(x_j)^2,\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 548 bytes). Transcript written on math.log.
何处 是重量。这个问题可以通过建立(典型的)超定矩阵方程来解决。
System Message: WARNING/2 (V(x) * c = w * Y)
latex exited with error [stdout] This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex) restricted \write18 enabled. entering extended mode (./math.tex LaTeX2e <2018-12-01> (/usr/share/texlive/texmf-dist/tex/latex/base/article.cls Document Class: article 2018/09/03 v1.4i Standard LaTeX document class (/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo)) (/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty For additional information on amsmath, use the `?' option. (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/share/texlive/texmf-dist/tex/latex/amscls/amsthm.sty) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (/usr/share/texlive/texmf-dist/tex/latex/anyfontsize/anyfontsize.sty) (/usr/share/texlive/texmf-dist/tex/latex/tools/bm.sty) (./math.aux) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd) (/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd) ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 \begin{split}V(x) * c = w * Y\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 \begin{split}V(x) * c = w * Y\end{split} ! Package inputenc Error: Unicode character ( (U+FF08) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 \begin{split}V(x) * c = w * Y\end{split} ! Package inputenc Error: Unicode character ) (U+FF09) (inputenc) not set up for use with LaTeX. See the inputenc package documentation for explanation. Type H <return> for immediate help. ... l.14 \begin{split}V(x) * c = w * Y\end{split} [1] (./math.aux) ) (see the transcript file for additional information) Output written on math.dvi (1 page, 356 bytes). Transcript written on math.log.
在哪里? V 是的加权伪范德蒙矩阵 x , c 是要求解的系数, w 是重量, y 是观察值。然后用奇异值分解法求解该方程。 V .
如果某些奇异值 V 是如此的小以至于被忽视,然后 RankWarning 将发布。这意味着系数值的确定可能很差。使用低阶拟合通常会消除警告。这个 rcond 也可以将参数设置为小于其默认值的值,但由此产生的拟合可能是虚假的,并且具有来自舍入误差的较大贡献。
当数据可以近似为 sqrt(w(x)) * p(x) 在哪里 w(x) 是隐士的重量。在这种情况下,重量 sqrt(w(x[i])) 应与数据值一起使用 y[i]/sqrt(w(x[i])) . 重量功能可用为 hermweight .
sqrt(w(x)) * p(x)
sqrt(w(x[i]))
y[i]/sqrt(w(x[i]))
工具书类
维基百科,“曲线拟合”,https://en.wikipedia.org/wiki/curve_fitting
实例
>>> from numpy.polynomial.hermite import hermfit, hermval >>> x = np.linspace(-10, 10) >>> err = np.random.randn(len(x))/10 >>> y = hermval(x, [1, 2, 3]) + err >>> hermfit(x, y, 2) array([1.0218, 1.9986, 2.9999]) # may vary