<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Factors in Simulator by using Variables for Monte Carlo Simulation in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215815#M43109</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I wonder to make monte carlo simulation by using the multiple dimensions listed in the data table (dt0), the N Rows of dt0 is dynamic upon user's inputs and requirements.&lt;/P&gt;&lt;P&gt;My question is how to use appropriate routine to add those dimensions in the Factors of Simulator?&lt;/P&gt;&lt;P&gt;I tried to use 'Substitute, Parse' function to make it work. But it only work when all those dimensions are listed in Factors().&lt;/P&gt;&lt;P&gt;Here is my scripts:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(
	Substitute(
			Expr(
				myanalysis = dt &amp;lt;&amp;lt; 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" ) &amp;lt;&amp;lt; No Noise ),
							Resimulate
						)
					),

				)
			),
		Expr( Dim A ), Parse( "Dim A&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim B ), Parse( "Dim B&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim C ), Parse( "Dim C&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim D ), Parse( "Dim D&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim E ), Parse( "Dim E&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim F ), Parse( "Dim F&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),

	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 02 Jul 2019 11:27:12 GMT</pubDate>
    <dc:creator>Adam_Xu</dc:creator>
    <dc:date>2019-07-02T11:27:12Z</dc:date>
    <item>
      <title>Factors in Simulator by using Variables for Monte Carlo Simulation</title>
      <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215815#M43109</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I wonder to make monte carlo simulation by using the multiple dimensions listed in the data table (dt0), the N Rows of dt0 is dynamic upon user's inputs and requirements.&lt;/P&gt;&lt;P&gt;My question is how to use appropriate routine to add those dimensions in the Factors of Simulator?&lt;/P&gt;&lt;P&gt;I tried to use 'Substitute, Parse' function to make it work. But it only work when all those dimensions are listed in Factors().&lt;/P&gt;&lt;P&gt;Here is my scripts:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Eval(
	Substitute(
			Expr(
				myanalysis = dt &amp;lt;&amp;lt; 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" ) &amp;lt;&amp;lt; No Noise ),
							Resimulate
						)
					),

				)
			),
		Expr( Dim A ), Parse( "Dim A&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim B ), Parse( "Dim B&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim C ), Parse( "Dim C&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim D ), Parse( "Dim D&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim E ), Parse( "Dim E&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),
		Expr( Dim F ), Parse( "Dim F&amp;lt;&amp;lt; Random( Normal( 1, 0.01 ) )" ),

	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 11:27:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215815#M43109</guid>
      <dc:creator>Adam_Xu</dc:creator>
      <dc:date>2019-07-02T11:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Factors in Simulator by using Variables for Monte Carlo Simulation</title>
      <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215936#M43130</link>
      <description>&lt;P&gt;Perhaps this code might point you in the right direction:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Fit Model(
				Y( yTBD ),
				Effects( xTBD ),
				Personality( "Standard Least Squares" ),
				Emphasis( "Effect Leverage" ),
				Run(
					Profiler(
						1,
						Simulator(
							1,
							Factors( xTBD &amp;lt;&amp;lt; Random( Normal( 80, 10 ) ) ),
							Responses( yTBD &amp;lt;&amp;lt; 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"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 16:53:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215936#M43130</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2019-07-02T16:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Factors in Simulator by using Variables for Monte Carlo Simulation</title>
      <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215979#M43139</link>
      <description>&lt;P&gt;Thank you so much, Ian!&lt;/P&gt;&lt;P&gt;It seems like the function works. However, with the scripts by following your advice, multiple profilers will be generated w/ only one Factor displayed in each profiler. I wonder to know how to display all Factors in one Profiler report. Do you have any comment? Appreciate it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my revised scripts:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;doSimulator=Function(
		{xVar, MeanVar, SigmaVar}, {Default Local},
		myFP=Expr(
			myProfiler=dt&amp;lt;&amp;lt;Profiler(
				Y( :Name( "TA Target" ) ),
				Profiler(
					1,
					Simulator(
						1,
						Factors(
							xTBD&amp;lt;&amp;lt;Random( Normal( MeanTBD, SigmaTBD ) ),
						),
						Responses( Name( "TA Target" ) &amp;lt;&amp;lt; No Noise ),
						Resimulate
					),
				);
			);
		);
		SubstituteInto(myFP, Expr(xTBD), Name Expr(xVar), Expr(MeanTBD), Name Expr(MeanVar), Expr(SigmaTBD), Name Expr(SigmaVar) );
		myFP;
		myProfiler;
	);
	
	For(i=1, i&amp;lt;=dimN, i++,
		cdimna=Col Stored Value(dt0,:Dim #, i);
		cdimme=Col Stored Value(dt0,:Mean,i);
		cdimsi=Col Stored Value(dt0,:Sigma,i);
		doSimulator(cdimna, cdimme, cdimsi);
	);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jul 2019 18:39:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/215979#M43139</guid>
      <dc:creator>Adam_Xu</dc:creator>
      <dc:date>2019-07-02T18:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: Factors in Simulator by using Variables for Monte Carlo Simulation</title>
      <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/216092#M43155</link>
      <description>&lt;P&gt;Yes, showing the report twice was just to illustrate that the function works.&lt;/P&gt;
&lt;P&gt;You can just build on the coding pattern above ('SubstituteInto()' can do any number of replacements). The analysis generated is not meaningful, but the code below is an example. The 'template expression' was built by JMP (with a few subsequent edits):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;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 &amp;lt;&amp;lt; Fit Model(
				Y( yTBD ),
				Effects( x1TBD, x2TBD ),
				Personality( "Standard Least Squares" ),
				Emphasis( "Effect Leverage" ),
				Run(
					Profiler(
						1,
						Simulator(
							1,
							Factors( 
								x1TBD &amp;lt;&amp;lt; Random( Normal( 290, 50 ) ),
								x2TBD &amp;lt;&amp;lt; Random( Normal( 460, 50 ) ) 									
								),
							Responses( yTBD &amp;lt;&amp;lt; 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"));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Jul 2019 09:03:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/216092#M43155</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2019-07-03T09:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: Factors in Simulator by using Variables for Monte Carlo Simulation</title>
      <link>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/216212#M43194</link>
      <description>&lt;P&gt;Thank you, Ian!&lt;/P&gt;&lt;P&gt;Maybe this is the most promising and feasible method by adding lots of variables in function list to get the Monte Carlo simulation by scripts based on current version of JMP.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2019 08:10:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Factors-in-Simulator-by-using-Variables-for-Monte-Carlo/m-p/216212#M43194</guid>
      <dc:creator>Adam_Xu</dc:creator>
      <dc:date>2019-07-04T08:10:30Z</dc:date>
    </item>
  </channel>
</rss>

