通過使用變量進行蒙特卡洛模擬的模擬器中的因素你好,
我想通過使用數據表(dt0)中列出的多個維度來進行蒙特卡洛模擬,dt0 的 N 行根據用戶的輸入和要求是動態的。
我的問題是如何使用適當的例程在模擬器的因素中添加這些維度?
我嘗試使用“替換、解析”功能使其工作。 但它只有在所有這些維度都列在 Factors() 中時才有效。
這是我的腳本:
Eval(
Substitute(
Expr(
myanalysis = dt << Profiler(
Y( :Name( "TA Target" ) ),
Profiler(
1,
Simulator(
1,
Factors( Dim A, Dim B, Dim C, Dim D, Dim E, Dim F, ),
Responses( Name( "TA Target" ) << No Noise ),
Resimulate
)
),
)
),
Expr( Dim A ), Parse( "Dim A<< Random( Normal( 1, 0.01 ) )" ),
Expr( Dim B ), Parse( "Dim B<< Random( Normal( 1, 0.01 ) )" ),
Expr( Dim C ), Parse( "Dim C<< Random( Normal( 1, 0.01 ) )" ),
Expr( Dim D ), Parse( "Dim D<< Random( Normal( 1, 0.01 ) )" ),
Expr( Dim E ), Parse( "Dim E<< Random( Normal( 1, 0.01 ) )" ),
Expr( Dim F ), Parse( "Dim F<< Random( Normal( 1, 0.01 ) )" ),
)
);回复:使用變量進行蒙特卡洛模擬的模擬器中的因素謝謝你,伊恩!
也許這是最有前途和可行的方法,在函數列表中添加大量變量,通過基於當前版本的 JMP 的腳本來獲得蒙特卡羅模擬。
回复:使用變量進行蒙特卡洛模擬的模擬器中的因素是的,兩次顯示報告只是為了說明該功能有效。
您可以在上面的編碼模式的基礎上構建('SubstituteInto()' 可以進行任意數量的替換)。 生成的分析沒有意義,但下面的代碼是一個例子。 “模板表達式”由 JMP 構建(隨後進行了一些編輯):
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Semiconductor Capability.jmp");
// Define a JSL function
doSimulator =
function({x1Var, x2Var, yVar}, {Default Local},
// Template expression
myFit = Expr(
fm = dt << Fit Model(
Y( yTBD ),
Effects( x1TBD, x2TBD ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
Profiler(
1,
Simulator(
1,
Factors(
x1TBD << Random( Normal( 290, 50 ) ),
x2TBD << Random( Normal( 460, 50 ) )
),
Responses( yTBD << No Noise ),
Resimulate
)
)
)
)
);
// Bake in the variablee passed to the function
SubstituteInto(myFit,
Expr(x1TBD), NameExpr(x1Var),
Expr(x2TBD), NameExpr(x2Var),
Expr(yTBD), NameExpr(yVar)
);
// Do the fit
myFit;
// Return the reference to the fit Model object
fm;
);
// Try out the function . . .
f = doSimulator(Column(dt, "PNP1"), Column(dt, "PNP2"), Column(dt, "NPN1"));回复:使用變量進行蒙特卡洛模擬的模擬器中的因素非常感謝,伊恩!
看起來這個功能有效。 但是,按照您的建議使用腳本,將生成多個分析器,每個分析器中僅顯示一個因子。 我想知道如何在一份 Profiler 報告中顯示所有因素。 你有什麼意見嗎? 欣賞它。
這是我修改後的腳本:
doSimulator=Function(
{xVar, MeanVar, SigmaVar}, {Default Local},
myFP=Expr(
myProfiler=dt<<PROFILER></PROFILER>回复:使用變量進行蒙特卡洛模擬的模擬器中的因素也許這段代碼可能會為您指明正確的方向:
NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
// Define a JSL function
doSimulator =
function({xVar, yVar}, {Default Local},
// Template expression
myFit = Expr(
fm = dt << Fit Model(
Y( yTBD ),
Effects( xTBD ),
Personality( "Standard Least Squares" ),
Emphasis( "Effect Leverage" ),
Run(
Profiler(
1,
Simulator(
1,
Factors( xTBD << Random( Normal( 80, 10 ) ) ),
Responses( yTBD << No Noise ),
Resimulate
)
)
)
)
);
// Bake in the variablee passed to the function
SubstituteInto(myFit, Expr(xTBD), NameExpr(xVar), Expr(yTBD), NameExpr(yVar));
// Do the fit
myFit;
// Return the reference to the fit Model object
fm;
);
// Try out the function . . .
fhw = doSimulator(Column(dt, "height"), Column(dt, "weight"));
fwh = doSimulator(Column(dt, "weight"), Column(dt, "height"));