<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166</link>
    <title>MATLAB Central Newsreader - Generating Random numbers</title>
    <description>Feed for thread: Generating Random numbers</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 02 Jul 2009 11:24:11 -0400</pubDate>
      <title>Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662158</link>
      <author>Deivy</author>
      <description>Hi Group,&lt;br&gt;
I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
the total of them would be 3000.&lt;br&gt;
How many numbers to generate is unknown but the generated numbers&lt;br&gt;
should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
How do I do this in matlab.&lt;br&gt;
Could someone help me with this.&lt;br&gt;
&lt;br&gt;
A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&lt;br&gt;
Thank you,&lt;br&gt;
Regards,&lt;br&gt;
Deivy</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 11:53:08 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662166</link>
      <author>arun</author>
      <description>On Jul 2, 1:24&#160;pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi Group,&lt;br&gt;
&amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thank you,&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; Deivy&lt;br&gt;
&lt;br&gt;
3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&lt;br&gt;
so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&lt;br&gt;
best,&lt;br&gt;
arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 11:58:01 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662168</link>
      <author>Deivy</author>
      <description>Hi Arun,&lt;br&gt;
Thanks for the reply.&lt;br&gt;
&lt;br&gt;
Thanks Deivy&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On Jul 2, 1:53&#160;pm, arun &amp;lt;aragorn1...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; On Jul 2, 1:24&#160;pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hi Group,&lt;br&gt;
&amp;gt; &amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; &amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; &amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; &amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; &amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; &amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
&amp;gt; getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
&amp;gt; would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
&amp;gt; suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; best,&lt;br&gt;
&amp;gt; arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 12:06:00 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662171</link>
      <author>Sadik </author>
      <description>Hi Deivy,&lt;br&gt;
&lt;br&gt;
You actually have two sets only. &lt;br&gt;
&lt;br&gt;
A = {500,500,500,500,500,500}&lt;br&gt;
&lt;br&gt;
and &lt;br&gt;
&lt;br&gt;
B = {600,600,600,600,600}&lt;br&gt;
&lt;br&gt;
The best way to see it is this. &lt;br&gt;
&lt;br&gt;
Average is the sum divided by the number of elements, right?&lt;br&gt;
&lt;br&gt;
Therefore, in any case, you can have at most 6 elements and at least 5 elements. This means that you have to have corresponding averages of 500 and 600. &lt;br&gt;
&lt;br&gt;
Looking at set A, the only way that you can achieve the average value of 500 is that all are equal to 500. Otherwise, you will have elements going below 500, which is not acceptable.&lt;br&gt;
&lt;br&gt;
A similar argument is valid for set B.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Deivy &amp;lt;deivy71@gmail.com&amp;gt; wrote in message &amp;lt;4d2b33d7-9115-449a-bd83-5ec410153f0b@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Arun,&lt;br&gt;
&amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks Deivy&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; On Jul 2, 1:53?pm, arun &amp;lt;aragorn1...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; On Jul 2, 1:24?pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi Group,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
&amp;gt; &amp;gt; getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
&amp;gt; &amp;gt; would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
&amp;gt; &amp;gt; suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; best,&lt;br&gt;
&amp;gt; &amp;gt; arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 12:13:30 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662175</link>
      <author>Deivy</author>
      <description>&lt;br&gt;
Hi Sadik,&lt;br&gt;
Thanks for the reply.&lt;br&gt;
The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&lt;br&gt;
What if the total is 4000, where it is not directly related to any of&lt;br&gt;
the numbers 500 and 600, and how do I do that.&lt;br&gt;
&lt;br&gt;
Thank you,&lt;br&gt;
Regards,&lt;br&gt;
Deivy&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On Jul 2, 2:06&#160;pm, &quot;Sadik &quot; &amp;lt;sadik.h...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Hi Deivy,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; You actually have two sets only.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; A = {500,500,500,500,500,500}&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; and&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; B = {600,600,600,600,600}&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; The best way to see it is this.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Average is the sum divided by the number of elements, right?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Therefore, in any case, you can have at most 6 elements and at least 5 elements. This means that you have to have corresponding averages of 500 and 600.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Looking at set A, the only way that you can achieve the average value of 500 is that all are equal to 500. Otherwise, you will have elements going below 500, which is not acceptable.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; A similar argument is valid for set B.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Hope this helps.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;4d2b33d7-9115-449a-bd83-5ec410153...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi Arun,&lt;br&gt;
&amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thanks Deivy&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; On Jul 2, 1:53?pm, arun &amp;lt;aragorn1...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; On Jul 2, 1:24?pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi Group,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; best,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 12:41:01 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662179</link>
      <author>Sadik </author>
      <description>One thing you could do is the following:&lt;br&gt;
&lt;br&gt;
A = (ceil(499.5+100*rand(10000,7)));&lt;br&gt;
indicesOf4000 = find(sum(A,2)==4000);&lt;br&gt;
&lt;br&gt;
Then, you could see the set of numbers by:&lt;br&gt;
&lt;br&gt;
for k = 1:length(indicesOf4000)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;disp(num2str(A(indicesOf4000,:)))&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
If indicesOf4000 seems to be blank, you could either run A = ... again, or you could increase the number of sample sets from 10000 to a higher value.&lt;br&gt;
&lt;br&gt;
Best.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Deivy &amp;lt;deivy71@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6ddb@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you,&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; Deivy&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; On Jul 2, 2:06?pm, &quot;Sadik &quot; &amp;lt;sadik.h...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hi Deivy,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; You actually have two sets only.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; A = {500,500,500,500,500,500}&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; and&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; B = {600,600,600,600,600}&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; The best way to see it is this.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Average is the sum divided by the number of elements, right?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Therefore, in any case, you can have at most 6 elements and at least 5 elements. This means that you have to have corresponding averages of 500 and 600.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Looking at set A, the only way that you can achieve the average value of 500 is that all are equal to 500. Otherwise, you will have elements going below 500, which is not acceptable.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; A similar argument is valid for set B.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hope this helps.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;4d2b33d7-9115-449a-bd83-5ec410153...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi Arun,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks Deivy&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; On Jul 2, 1:53?pm, arun &amp;lt;aragorn1...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; On Jul 2, 1:24?pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi Group,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; best,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 12:45:02 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662181</link>
      <author>Sadik </author>
      <description>The display line should have been:&lt;br&gt;
&lt;br&gt;
disp(num2str(A(indicesOf4000(k),:)))&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Deivy &amp;lt;deivy71@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6ddb@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you,&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; Deivy&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; On Jul 2, 2:06?pm, &quot;Sadik &quot; &amp;lt;sadik.h...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Hi Deivy,&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; You actually have two sets only.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; A = {500,500,500,500,500,500}&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; and&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; B = {600,600,600,600,600}&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; The best way to see it is this.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Average is the sum divided by the number of elements, right?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Therefore, in any case, you can have at most 6 elements and at least 5 elements. This means that you have to have corresponding averages of 500 and 600.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Looking at set A, the only way that you can achieve the average value of 500 is that all are equal to 500. Otherwise, you will have elements going below 500, which is not acceptable.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; A similar argument is valid for set B.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hope this helps.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;4d2b33d7-9115-449a-bd83-5ec410153...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi Arun,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks Deivy&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; On Jul 2, 1:53?pm, arun &amp;lt;aragorn1...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; On Jul 2, 1:24?pm, Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi Group,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; I would like to generate a set of numbers between 500 and 600 so that&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; the total of them would be 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; How many numbers to generate is unknown but the generated numbers&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; should be within the range of 500 to 600 they should total to 3000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; How do I do this in matlab.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Could someone help me with this.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; A small script that accomplishes this task is highly appreciated.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; 3000 = 500 * 6 = 600 * 5.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; so, the numbers you generate should be able to accomplish the task of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; getting a sum of 3000 in 5 or 6 random numbers, otherwise the sum&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; would exceed 3000. so, its either 5 or 6. and they are not random, I&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; suppose.. unless the sum is &amp;gt;= 3000 but not == 3000.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; best,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; arun.</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 12:45:02 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662182</link>
      <author>John D'Errico</author>
      <description>Deivy &amp;lt;deivy71@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6ddb@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt; &lt;br&gt;
&lt;br&gt;
You should recognize that this is not possible in some&lt;br&gt;
circumstances, and certainly will not be a random set&lt;br&gt;
of numbers. &lt;br&gt;
&lt;br&gt;
For example, write the number 2401 as the sum of ANY&lt;br&gt;
size set of numbers in the range [500,600]. It cannot&lt;br&gt;
be done.&lt;br&gt;
&lt;br&gt;
Or, write 2500 as such a sum? It turns out there is only&lt;br&gt;
one such solution, 2500 = 500 + 500 + 500 + 500 + 500.&lt;br&gt;
You may not think of this solution as a random set.&lt;br&gt;
&lt;br&gt;
Regardless, even if a solution exists that is not unique,&lt;br&gt;
it is not random in the common sense of the word, since&lt;br&gt;
given the first n-1 members of the set, the last member&lt;br&gt;
is uniquely determined to meet the sum criterion.&lt;br&gt;
&lt;br&gt;
If you still insist on finding a random looking set of&lt;br&gt;
numbers that satisfy your sum constraint, use a simple&lt;br&gt;
logic:&lt;br&gt;
&lt;br&gt;
How many terms will the sum be composed of?&lt;br&gt;
&lt;br&gt;
7*500 = 3500, and 8*500 = 4000.&lt;br&gt;
7*600 = 4200&lt;br&gt;
&lt;br&gt;
Therefore, the sum must be composed of 7 numbers in&lt;br&gt;
that range.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;x = 500 + 100*rand(1,7);&lt;br&gt;
&amp;nbsp;x = x * 4000/sum(x);&lt;br&gt;
&lt;br&gt;
John</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 13:18:49 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662199</link>
      <author>Deivy</author>
      <description>Hi Sadik &amp; John,&lt;br&gt;
Thank you for your replies.&lt;br&gt;
&lt;br&gt;
Sadik,&lt;br&gt;
when such a solution exists how do I extract to another matrix or wite&lt;br&gt;
to a text file.&lt;br&gt;
&lt;br&gt;
Thank you,&lt;br&gt;
Regards,&lt;br&gt;
Deivy&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On Jul 2, 2:45&#160;pm, &quot;John D'Errico&quot; &amp;lt;woodch...@rochester.rr.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; &amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; You should recognize that this is not possible in some&lt;br&gt;
&amp;gt; circumstances, and certainly will not be a random set&lt;br&gt;
&amp;gt; of numbers.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; For example, write the number 2401 as the sum of ANY&lt;br&gt;
&amp;gt; size set of numbers in the range [500,600]. It cannot&lt;br&gt;
&amp;gt; be done.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Or, write 2500 as such a sum? It turns out there is only&lt;br&gt;
&amp;gt; one such solution, 2500 = 500 + 500 + 500 + 500 + 500.&lt;br&gt;
&amp;gt; You may not think of this solution as a random set.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Regardless, even if a solution exists that is not unique,&lt;br&gt;
&amp;gt; it is not random in the common sense of the word, since&lt;br&gt;
&amp;gt; given the first n-1 members of the set, the last member&lt;br&gt;
&amp;gt; is uniquely determined to meet the sum criterion.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; If you still insist on finding a random looking set of&lt;br&gt;
&amp;gt; numbers that satisfy your sum constraint, use a simple&lt;br&gt;
&amp;gt; logic:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; How many terms will the sum be composed of?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; 7*500 = 3500, and 8*500 = 4000.&lt;br&gt;
&amp;gt; 7*600 = 4200&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Therefore, the sum must be composed of 7 numbers in&lt;br&gt;
&amp;gt; that range.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &#160;x = 500 + 100*rand(1,7);&lt;br&gt;
&amp;gt; &#160;x = x * 4000/sum(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; John</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 13:34:01 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662205</link>
      <author>Sadik </author>
      <description>B = A(indicesOf4000,:);&lt;br&gt;
&lt;br&gt;
should give you the matrix. &lt;br&gt;
&lt;br&gt;
In order to write to the text file, you need to do the following:&lt;br&gt;
&lt;br&gt;
fid = fopen('C:\4000.txt','w');&lt;br&gt;
fprintf(fid,'%d %d %d %d %d %d %d \n',A(indicesOf4000,:));&lt;br&gt;
fclose(fid);&lt;br&gt;
&lt;br&gt;
You could open the file using wordpad and you will hopefully see the numbers in a regular manner.&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Deivy &amp;lt;deivy71@gmail.com&amp;gt; wrote in message &amp;lt;8f91f9c6-aacc-4e38-92d7-1608eeb61076@a7g2000yqk.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi Sadik &amp; John,&lt;br&gt;
&amp;gt; Thank you for your replies.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Sadik,&lt;br&gt;
&amp;gt; when such a solution exists how do I extract to another matrix or wite&lt;br&gt;
&amp;gt; to a text file.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thank you,&lt;br&gt;
&amp;gt; Regards,&lt;br&gt;
&amp;gt; Deivy&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; On Jul 2, 2:45?pm, &quot;John D'Errico&quot; &amp;lt;woodch...@rochester.rr.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; You should recognize that this is not possible in some&lt;br&gt;
&amp;gt; &amp;gt; circumstances, and certainly will not be a random set&lt;br&gt;
&amp;gt; &amp;gt; of numbers.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; For example, write the number 2401 as the sum of ANY&lt;br&gt;
&amp;gt; &amp;gt; size set of numbers in the range [500,600]. It cannot&lt;br&gt;
&amp;gt; &amp;gt; be done.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Or, write 2500 as such a sum? It turns out there is only&lt;br&gt;
&amp;gt; &amp;gt; one such solution, 2500 = 500 + 500 + 500 + 500 + 500.&lt;br&gt;
&amp;gt; &amp;gt; You may not think of this solution as a random set.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Regardless, even if a solution exists that is not unique,&lt;br&gt;
&amp;gt; &amp;gt; it is not random in the common sense of the word, since&lt;br&gt;
&amp;gt; &amp;gt; given the first n-1 members of the set, the last member&lt;br&gt;
&amp;gt; &amp;gt; is uniquely determined to meet the sum criterion.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; If you still insist on finding a random looking set of&lt;br&gt;
&amp;gt; &amp;gt; numbers that satisfy your sum constraint, use a simple&lt;br&gt;
&amp;gt; &amp;gt; logic:&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; How many terms will the sum be composed of?&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; 7*500 = 3500, and 8*500 = 4000.&lt;br&gt;
&amp;gt; &amp;gt; 7*600 = 4200&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Therefore, the sum must be composed of 7 numbers in&lt;br&gt;
&amp;gt; &amp;gt; that range.&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; ?x = 500 + 100*rand(1,7);&lt;br&gt;
&amp;gt; &amp;gt; ?x = x * 4000/sum(x);&lt;br&gt;
&amp;gt; &amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; John</description>
    </item>
    <item>
      <pubDate>Thu, 02 Jul 2009 13:37:32 -0400</pubDate>
      <title>Re: Generating Random numbers</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/255166#662206</link>
      <author>Deivy</author>
      <description>Hi Sadik,&lt;br&gt;
Thank you very much.&lt;br&gt;
&lt;br&gt;
I am still tring and the code works fine but for different numbers and&lt;br&gt;
ranges I have to tweak I guess.&lt;br&gt;
Anyway, Thanks a lot for all the help.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you,&lt;br&gt;
Regards,&lt;br&gt;
Deivy&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
On Jul 2, 3:34&#160;pm, &quot;Sadik &quot; &amp;lt;sadik.h...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; B = A(indicesOf4000,:);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; should give you the matrix.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; In order to write to the text file, you need to do the following:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; fid = fopen('C:\4000.txt','w');&lt;br&gt;
&amp;gt; fprintf(fid,'%d %d %d %d %d %d %d \n',A(indicesOf4000,:));&lt;br&gt;
&amp;gt; fclose(fid);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; You could open the file using wordpad and you will hopefully see the numbers in a regular manner.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Hope this helps.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;8f91f9c6-aacc-4e38-92d7-1608eeb61...@a7g2000yqk.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi Sadik &amp; John,&lt;br&gt;
&amp;gt; &amp;gt; Thank you for your replies.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Sadik,&lt;br&gt;
&amp;gt; &amp;gt; when such a solution exists how do I extract to another matrix or wite&lt;br&gt;
&amp;gt; &amp;gt; to a text file.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; Thank you,&lt;br&gt;
&amp;gt; &amp;gt; Regards,&lt;br&gt;
&amp;gt; &amp;gt; Deivy&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; On Jul 2, 2:45?pm, &quot;John D'Errico&quot; &amp;lt;woodch...@rochester.rr.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Deivy &amp;lt;deiv...@gmail.com&amp;gt; wrote in message &amp;lt;1602c78c-e855-4e3b-a483-4fa3ecba6...@h8g2000yqm.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Hi Sadik,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; Thanks for the reply.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; The choice of 3000 was accidental and it made the case bit easier.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; What if the total is 4000, where it is not directly related to any of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; &amp;gt; the numbers 500 and 600, and how do I do that.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; You should recognize that this is not possible in some&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; circumstances, and certainly will not be a random set&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; of numbers.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; For example, write the number 2401 as the sum of ANY&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; size set of numbers in the range [500,600]. It cannot&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; be done.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Or, write 2500 as such a sum? It turns out there is only&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; one such solution, 2500 = 500 + 500 + 500 + 500 + 500.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; You may not think of this solution as a random set.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Regardless, even if a solution exists that is not unique,&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; it is not random in the common sense of the word, since&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; given the first n-1 members of the set, the last member&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; is uniquely determined to meet the sum criterion.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; If you still insist on finding a random looking set of&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; numbers that satisfy your sum constraint, use a simple&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; logic:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; How many terms will the sum be composed of?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 7*500 = 3500, and 8*500 = 4000.&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; 7*600 = 4200&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; Therefore, the sum must be composed of 7 numbers in&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; that range.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ?x = 500 + 100*rand(1,7);&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; ?x = x * 4000/sum(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; &amp;gt; John</description>
    </item>
  </channel>
</rss>

