<?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: Random number between 1 and N in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Random-number-between-1-and-N/m-p/962603#M22136</link>
    <description>When you say "m &amp;lt;= N", that implies to me that you don't want any duplicates in the set.  (If so, then they're not really random.)  You can do this, but the technique differs.&lt;BR /&gt;&lt;BR /&gt;Given a value R from RANDOM_NUMBER, you get an integer between 1 and N by doing &lt;PRE&gt; INT(R * REAL(N)) + 1&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;If you want no duplicates, then you have to allocate an array of size N in which you record whether or not you've already seen each value. If you have, try again.  There are various optimizations you can do on top of this.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
    <pubDate>Tue, 14 Aug 2001 08:41:35 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2001-08-14T08:41:35Z</dc:date>
    <item>
      <title>Random number between 1 and N</title>
      <link>https://community.intel.com/t5/Software-Archive/Random-number-between-1-and-N/m-p/962602#M22135</link>
      <description>Thank you very much for your replies. Indeed, my question is how to generate a set of random numbers, say m random numbers, between 1 and N. Here m and N are integers and m &amp;lt;= N.  Also, when the program is excuted each time, these m random numbers should be different.</description>
      <pubDate>Tue, 14 Aug 2001 08:28:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Random-number-between-1-and-N/m-p/962602#M22135</guid>
      <dc:creator>Intel_C_Intel</dc:creator>
      <dc:date>2001-08-14T08:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Random number between 1 and N</title>
      <link>https://community.intel.com/t5/Software-Archive/Random-number-between-1-and-N/m-p/962603#M22136</link>
      <description>When you say "m &amp;lt;= N", that implies to me that you don't want any duplicates in the set.  (If so, then they're not really random.)  You can do this, but the technique differs.&lt;BR /&gt;&lt;BR /&gt;Given a value R from RANDOM_NUMBER, you get an integer between 1 and N by doing &lt;PRE&gt; INT(R * REAL(N)) + 1&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;If you want no duplicates, then you have to allocate an array of size N in which you record whether or not you've already seen each value. If you have, try again.  There are various optimizations you can do on top of this.&lt;BR /&gt;&lt;BR /&gt;Steve</description>
      <pubDate>Tue, 14 Aug 2001 08:41:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Random-number-between-1-and-N/m-p/962603#M22136</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2001-08-14T08:41:35Z</dc:date>
    </item>
  </channel>
</rss>

