使用Javascript预测二阶多项式序列中的下一个值 [英] Predict the next value in a 2nd order polynomial sequence with Javascript

查看:53
本文介绍了使用Javascript预测二阶多项式序列中的下一个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想给一个Javascript函数一个数组,然后按照一段时间推断前进 -



例如



var numArray = [0,1,2,3,4,5]



var myFunction = function(array,period){}



所以myFunction(numArray,7)将返回'6'而myFunction(numArray,8)将返回'7'



我想我可以使这个工作为线性最小二乘,但是我如何使它适用于二次多项式?



谢谢



MV

解决方案

这个例子是在c#中,但文章中的代码应该是公平的易于翻译。



加权线性回归算法 [ ^ ]

I'd like to give a Javascript function an array and then extrapolate forwards by a number of periods -

eg

var numArray = [0,1,2,3,4,5]

var myFunction = function(array,period){}

So myFunction(numArray,7) would return '6' and myFunction(numArray,8) would return '7'

I think I can make this work for a linear least squares, but how would I make it work for a 2nd degree polynomial?

Thank you

MV

解决方案

This is example is in c#, but the code in the article should be fairly easy to translate.

An Algorithm for Weighted Linear Regression[^]


这篇关于使用Javascript预测二阶多项式序列中的下一个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆