<?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 Re: How do I automate random sampling generation from different distribution types? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357199#M60725</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;A couple thoughts:&lt;BR /&gt;1) If possible, I would split the parameters across columns to make the scripting of the formula easier&lt;BR /&gt;2) I would use the MATCH formula to look for the name of the distribution and specifically call the Random function for the corresponding distribution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Match( :Distribution,
	"Normal", Random Normal( :Parameter 1, :Parameter 2 ),
	"LogNormal", Random Lognormal( :Parameter 1, :Parameter 2 ),
	.
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 08 Feb 2021 16:54:49 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2021-02-08T16:54:49Z</dc:date>
    <item>
      <title>How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357194#M60724</link>
      <description>&lt;P&gt;Let's say I have a table with 5 rows &amp;amp; 2 columns. The first column is for distribution types (e.g. Normal, Lognormal, Weibull, etc) and the second column is for the respective parameters. I'd like to make a for loop which will create a new data table for each of the 5 rows, where in that new data table, a new column will be added with a random sampling function based on the parameters of the row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g. row 1 --&amp;gt; Normal, (0.1,0.02); Create a new data table with a column that has a formula of&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;randomnormal(0.1,0.02)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;My current challenge is that different distribution types require varying number of parameters. Appreciate some insights on how I should approach this.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:05:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357194#M60724</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2023-06-09T22:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357199#M60725</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;A couple thoughts:&lt;BR /&gt;1) If possible, I would split the parameters across columns to make the scripting of the formula easier&lt;BR /&gt;2) I would use the MATCH formula to look for the name of the distribution and specifically call the Random function for the corresponding distribution&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Match( :Distribution,
	"Normal", Random Normal( :Parameter 1, :Parameter 2 ),
	"LogNormal", Random Lognormal( :Parameter 1, :Parameter 2 ),
	.
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:54:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357199#M60725</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-02-08T16:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357207#M60726</link>
      <description>&lt;P&gt;Here is a simple example of how to do what you requested&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = New Table( "Sample",
	Add Rows( 5 ),
	New Column( "Types",
		Character,
		Set Values(
			{"Normal", "Lognormal", "Weibull", "Uniform", "Johnson Su"}
		),
		Set Display Width( 79 )
	),
	New Column( "Parameters",
		Character,
		Set Values(
			{"(0.1,0.02)", "(0.2,.005)", "(0.3,0.005)", "(0.1,0.5)",
			"(0.5, 1, 1, 1)"}
		),
		Set Display Width( 101 )
	)
);

For( i = 1, i &amp;lt;= N Rows( dt ), i++,
	Eval(
		Substitute(
				Expr(
					New Table( dt:Types[i],
						add rows( 20 ),
						New Column( "Random " || dt:Types[i],
							set each value( __formula__ )
						)
					)
				),
			Expr( __formula__ ),
				Parse( "Random " || dt:Types[i] || dt:Parameters[i] )
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Please take the time to fully understand how the script works, and if you do not understand it, please respond back so the Community can provide you with the additional information you may need.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:06:29 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357207#M60726</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-02-08T17:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357210#M60727</link>
      <description>&lt;P&gt;Thanks Thierry, any suggestions if I want to limit the number of columns for the parameters ?&lt;/P&gt;&lt;P&gt;Another concern that I have is, I believe the Match() formula is case sensitive. I can try to control this by putting a List Check on the column. Are there other ways to control / manage that ?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:07:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357210#M60727</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2021-02-08T17:07:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357222#M60729</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the case sensitive issue, here is the fix:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Match( Uppercase( :Distribution ),
	"NORMAL", Random Normal( :Parameter 1, :Parameter 2 ),
	"LOGNORMAL", Random Lognormal( :Parameter 1, :Parameter 2 ),
	.
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;About limiting the number of columns, I will get back to you because it is a little bit trickier.&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;TS&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:43:19 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357222#M60729</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2021-02-08T17:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I automate random sampling generation from different distribution types?</title>
      <link>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357820#M60792</link>
      <description>&lt;P&gt;It works Jim! Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2021 13:40:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-do-I-automate-random-sampling-generation-from-different/m-p/357820#M60792</guid>
      <dc:creator>Djtjhin</dc:creator>
      <dc:date>2021-02-10T13:40:18Z</dc:date>
    </item>
  </channel>
</rss>

