我有一個運行多次的遞回演算法,currentValue每次都用上一次運行的輸出替換(第一次運行除外,其中值由用戶提供)。每次運行都會計算一年后的值。
value = constant
population_factor * coeff_population_factor
currentValue * coeff_currentValue
initialValue * coeff_initialValue%
duration_of_period * coeff_duration_of_period
我希望能夠將其轉換為時間函式,這樣對于給定t的年值,它會回傳當時的預期值?我認為這將是一個回歸演算法,但我不知道如何做到這一點。
我已經在excel中使用上面的公式對曲線進行了建模以獲得我的系數,但這顯然只能在我的計算機上運行,??我想使用節點或其他東西在云中運行它,所以我可以開發一些前端來對抗它。理想情況下,一些使用純數學或 JS 或庫的指標,甚至,將不勝感激!
uj5u.com熱心網友回復:
我相信你正在尋找一個 for 回圈。試試這個:
# define all of the variables here
currentValue = #put the first-run value here
for i in range(t):
currentValue = constant \
(population_factor * coeff_population_factor) \
(currentValue * coeff_currentValue) \
(initialValue * coeff_initialValue) \
(duration_of_period * coeff_duration_of_period)
# currentValue will have the final result once outside of the for loop
它不是遞回的,仍然給出準確的答案!
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/424827.html
標籤:javascript 数学 统计数据
上一篇:獲取點到中心點的角度和距離
下一篇:如何找到勒讓德的符號?
