用变量进行蒙特卡罗模拟的模拟器因素你好,
我想通过使用数据表(dt0)中列出的多个维度进行蒙特卡罗模拟,dt0的N行是根据用户的输入和要求动态的。
我的问题是如何使用适当的例程在模拟器的因素中添加这些维度?
我尝试使用'Substitute,Parse'功能使其工作。但它只有在所有这些维度列在因子()中时才有效。
这是我的脚本:
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 ) )" ),
)
);Re:使用变量进行蒙特卡罗模拟的模拟器中的因子也许这段代码可能会指向正确的方向:
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"));Re:使用变量进行蒙特卡罗模拟的模拟器中的因子非常感谢你,伊恩!
似乎功能有效。但是,根据您的建议使用脚本,将生成多个分析器,每个分析器中只显示一个因子。我想知道如何在一个Profiler报告中显示所有因子。你有什么评论吗?欣赏它。
这是我修改过的脚本:
doSimulator=Function(
{xVar, MeanVar, SigmaVar}, {Default Local},
myFP=Expr(
myProfiler=dt<<PROFILER></PROFILER>Re:使用变量进行蒙特卡罗模拟的模拟器中的因子是的,两次显示报告只是为了说明该功能是有效的。
你可以建立在上面的编码模式('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"));Re:使用变量进行蒙特卡罗模拟的模拟器中的因子谢谢,伊恩!
也许这是最有前途和最可行的方法,通过在函数列表中添加大量变量来获得基于当前版本的JMP的脚本进行蒙特卡罗模拟。