在 JSL 中循環導數函數
大家好,JMP 用戶社區,我一直在努力解決 JSL 函數的問題,想聯繫一下大家,看看能否提供幫助。
因此,我希望腳本執行的操作基本上是從多項式迴歸模型中取得公式表達式,然後針對每個包含的因子建立偏導數。理想情況下,它會建立一個包含表達式公式中包含的所有因子的清單。然後循環遍歷該列表,並將一個又一個的因子代入導數函數中,以計算所有偏導數公式並分別保存它們。問題是,我不知道如何建立這樣一個循環,並以導函數可以接受的方式格式化因子名稱。我已經嘗試了很多方法,但似乎都沒有用。我附在 JSL 範例文件中的只有兩種能夠正確計算偏導數的方法。
有人用過這個函數嗎?或是能幫我創建循環中導數函數的正確輸入格式嗎?非常感謝!
自動化和腳本回覆:在 JSL 中循環導數函數你可以將項目評估為衍生性商品
Names Default To Here(1);
formula_expr = Expr(
48.5137619590147 + -5.01848924914286 * :"Factor 1"n + -6.30434548201033 * :"Factor 2"n
+4.98953779772742 * :"Factor 3"n + 4.94156314686837 * :"Factor 4"n + -8.10632041659685 *
:"Factor 5"n + -15.9138137782692 * :"Factor 1"n * :"Factor 1"n + 5.67284677635098 *
:"Factor 2"n * :"Factor 2"n
);
///// Working example 1
derivative_expr = Derivative(Name Expr(formula_expr), :Name("Factor 1"));
Show(derivative_expr);
///// Working example 2
derivative_expr = Derivative(Name Expr(formula_expr), :"Factor 1"n);
Show(derivative_expr);
//// What the loop should look like (not working)
factorList = {:"Factor 1"n, :"Factor 2"n, :"Factor 3"n, :"Factor 4"n, :"Factor 5"n};
For Each({factor_item}, factorList,
derivative_expr = Eval(EvalExpr(
Derivative(Name Expr(formula_expr), Expr(Name Expr(factor_item)));
));
Show(derivative_expr);
);
回覆:在 JSL 中循環導數函數非常感謝 jthi!解決了問題:)我已在我的腳本中成功實現它。
我非常感謝你的幫助