<?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 Comment échantillonner une colonne ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843638#M101745</link>
    <description>&lt;P&gt;Dans une première colonne je simule une variable aléatoire pour créer une population (par exemple, 10000 lignes avec une loi normale).&lt;/P&gt;&lt;P&gt;Ensuite, j'aimerais, dans une autre colonne obtenir un échantillon aléatoire de taille n à fixer et extrait de la population créée dans la colonne précédente. Le top, serait d'obtenir plusieurs échantillons simultanément dans des colonnes juxtaposées.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pour info, je découvre JMP que depuis quelques semaines (je travaille depuis des années avec Minitab), je n'ai pas trouvé la solution tout seul, si ce n'est un échantillonnage lors de la création d'un graphique.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Par avance, merci.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Feb 2025 22:14:11 GMT</pubDate>
    <dc:creator>rugolf</dc:creator>
    <dc:date>2025-02-21T22:14:11Z</dc:date>
    <item>
      <title>Comment échantillonner une colonne ?</title>
      <link>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843638#M101745</link>
      <description>&lt;P&gt;Dans une première colonne je simule une variable aléatoire pour créer une population (par exemple, 10000 lignes avec une loi normale).&lt;/P&gt;&lt;P&gt;Ensuite, j'aimerais, dans une autre colonne obtenir un échantillon aléatoire de taille n à fixer et extrait de la population créée dans la colonne précédente. Le top, serait d'obtenir plusieurs échantillons simultanément dans des colonnes juxtaposées.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Pour info, je découvre JMP que depuis quelques semaines (je travaille depuis des années avec Minitab), je n'ai pas trouvé la solution tout seul, si ce n'est un échantillonnage lors de la création d'un graphique.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Par avance, merci.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Feb 2025 22:14:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843638#M101745</guid>
      <dc:creator>rugolf</dc:creator>
      <dc:date>2025-02-21T22:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: Comment échantillonner une colonne ?</title>
      <link>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843657#M101748</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are multiple ways to do this.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The simplest is to use the built in capability of the Subset platform&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Subset&lt;/P&gt;
&lt;P&gt;Given a table with a column of data with 1000 rows&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1740184285276.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73256iC3FE75932E6B71DD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1740184285276.png" alt="txnelson_0-1740184285276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The Tables=&amp;gt;Subset allow you to create a random sample of either a given percentage or a given sample size&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1740184470825.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73257iAA615457E2F162D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1740184470825.png" alt="txnelson_1-1740184470825.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which will give you a new table with 100 rows&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1740184553796.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73258i12817499AE48FDC6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_2-1740184553796.png" alt="txnelson_2-1740184553796.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;it is then a simple matter to join this table with the original table using&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Tables=&amp;gt;Join&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_4-1740184746639.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73260iD557FDCFEF2BF479/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_4-1740184746639.png" alt="txnelson_4-1740184746639.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which will give you what you asked for&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_6-1740184920107.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73262i46066108E911668B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_6-1740184920107.png" alt="txnelson_6-1740184920107.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The main problem with this approach is that it is somewhat violating the assumptions of a JMP data table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another approach would be to use a column formula.&amp;nbsp; The formula I came up with produces a random sample, but rather than placing the selected data into the first 100 rows, it places the values in the row the selected data comes from.&lt;/P&gt;
&lt;P&gt;Here is the formula&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;As Constant(
	rowCount = N Rows( Current Data Table() );
	sampleMatrix = [];
	For( i = 1, i &amp;lt;= 100, i++,
		found = 0;
		While( found == 0,
			row = Random Integer( 1, rowCount );
			If( N Rows( Loc( sampleMatrix, row ) ) == 0,
				found = 1;
				sampleMatrix = sampleMatrix || Matrix( row );
			);
		);
	);
);
If( N Cols( Loc( sampleMatrix, Row() ) ) != 0,
	:Column 1,
	.
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which produces&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1740189189597.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73264i2E4D7566B5690C5F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1740189189597.png" alt="txnelson_0-1740189189597.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now if one moves the sample generation to JSL, it becomes a fairly easy task to create as many samples as needed&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
rowCount = N Rows( dt );
	
// Create 5 Random Samples of 100
For( k = 1, k &amp;lt;= 5, k++,
	dt &amp;lt;&amp;lt; New Column( "Random" || Char( k ) );
	sampleMatrix = [];
	For( i = 1, i &amp;lt;= 100, i++,
		found = 0;
		While( found == 0,
			row = Random Integer( 1, rowCount );
			If( N Rows( Loc( sampleMatrix, row ) ) == 0,
				found = 1;
				sampleMatrix = sampleMatrix || Matrix( row );
			);
		);
	);

// Write the values to the new column
	For Each( {row}, sampleMatrix,
		Column( "Random" || Char( k ) )[row] = :Column 1[row]
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which creates&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_1-1740190043651.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73265i735FEF1C7C411909/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_1-1740190043651.png" alt="txnelson_1-1740190043651.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;With a little modification, the random sample generation can be sampling without replacement&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();
rowCount = N Rows( dt );
masterSampleMatrix = [];
	
// Create 5 Random Samples of 100
For( k = 1, k &amp;lt;= 5, k++,
	dt &amp;lt;&amp;lt; New Column( "Random" || Char( k ) );
	sampleMatrix = [];
	For( i = 1, i &amp;lt;= 100, i++,
		found = 0;
		While( found == 0,
			row = Random Integer( 1, rowCount );
			If( N Rows( Loc( masterSampleMatrix, row ) ) == 0,
				found = 1;
				sampleMatrix = sampleMatrix || Matrix( row );
				masterSampleMatrix = masterSampleMatrix || Matrix( row );
			);
		);
	);

// Write the values to the new column
	For Each( {row}, sampleMatrix,
		Column( "Random" || Char( k ) )[row] = :Column 1[row]
	);
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_2-1740190597506.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/73266iA9C16C0483D7192B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_2-1740190597506.png" alt="txnelson_2-1740190597506.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2025 02:16:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843657#M101748</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2025-02-22T02:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Comment échantillonner une colonne ?</title>
      <link>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843742#M101753</link>
      <description>&lt;P&gt;Merci beaucoup.&lt;/P&gt;&lt;P&gt;JL&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2025 19:31:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Comment-%C3%A9chantillonner-une-colonne/m-p/843742#M101753</guid>
      <dc:creator>rugolf</dc:creator>
      <dc:date>2025-02-22T19:31:06Z</dc:date>
    </item>
  </channel>
</rss>

