迫切需要一个与 Matlab 中存在的 polyval 和 polyfit 函数等效的 Javascript。本质上,matlab 中的那些函数根据指定的多项式基于两个大小相等的数组进行曲线拟合。我需要在 javascript 中进行一些涉及曲线拟合的计算,但我一辈子都找不到等效的函数。
这是MatLab对函数polyfit的解释
"P = POLYFIT(X,Y,N) finds the coefficients of a polynomial P(X) of degree N that fits the data Y best in a least-squares sense. P is a row vector of length N+1 containing the polynomial coefficients in descending powers, P(1)*X^N + P(2)*X^(N-1) +...+ P(N)*X + P(N+1)."
这是MatLab对polyval的解释
"POLYVAL Evaluate polynomial. Y = POLYVAL(P,X) returns the value of a polynomial P evaluated at X. P is a vector of length N+1 whose elements are the coefficients of the polynomial in descending powers.
Y = P(1)*X^N + P(2)*X^(N-1) + ... + P(N)*X + P(N+1)"
任何帮助都会很棒。
问候,
最佳答案
numericjs可能会帮助您入门。
关于与 Matlab 函数 : Polyfit/Polyval? 等效的 Javascript 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6826522/