Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!a7g2000yqk.googlegroups.com!not-for-mail
From: Deivy <deivy71@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Generating Random numbers
Date: Thu, 2 Jul 2009 06:18:49 -0700 (PDT)
Organization: http://groups.google.com
Lines: 60
Message-ID: <8f91f9c6-aacc-4e38-92d7-1608eeb61076@a7g2000yqk.googlegroups.com>
References: <d639c2c7-c672-4177-b89b-5c584755dabc@x5g2000yqk.googlegroups.com> 
	<1602c78c-e855-4e3b-a483-4fa3ecba6ddb@h8g2000yqm.googlegroups.com> 
	<h2ia4e$3at$1@fred.mathworks.com>
NNTP-Posting-Host: 130.238.8.198
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1246540729 26404 127.0.0.1 (2 Jul 2009 13:18:49 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Thu, 2 Jul 2009 13:18:49 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: a7g2000yqk.googlegroups.com; posting-host=130.238.8.198; 
	posting-account=twjtNAoAAAD5eFO488SppmbV-BtF0_IO
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us) 
	AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Safari/530.17,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.soft-sys.matlab:552374


Hi Sadik & John,
Thank you for your replies.

Sadik,
when such a solution exists how do I extract to another matrix or wite
to a text file.

Thank you,
Regards,
Deivy





On Jul 2, 2:45 pm, "John D'Errico" <woodch...@rochester.rr.com> wrote:
> Deivy <deiv...@gmail.com> wrote in message <1602c78c-e855-4e3b-a483-4fa3ecba6...@h8g2000yqm.googlegroups.com>...
>
> > Hi Sadik,
> > Thanks for the reply.
> > The choice of 3000 was accidental and it made the case bit easier.
>
> > What if the total is 4000, where it is not directly related to any of
> > the numbers 500 and 600, and how do I do that.
>
> You should recognize that this is not possible in some
> circumstances, and certainly will not be a random set
> of numbers.
>
> For example, write the number 2401 as the sum of ANY
> size set of numbers in the range [500,600]. It cannot
> be done.
>
> Or, write 2500 as such a sum? It turns out there is only
> one such solution, 2500 = 500 + 500 + 500 + 500 + 500.
> You may not think of this solution as a random set.
>
> Regardless, even if a solution exists that is not unique,
> it is not random in the common sense of the word, since
> given the first n-1 members of the set, the last member
> is uniquely determined to meet the sum criterion.
>
> If you still insist on finding a random looking set of
> numbers that satisfy your sum constraint, use a simple
> logic:
>
> How many terms will the sum be composed of?
>
> 7*500 = 3500, and 8*500 = 4000.
> 7*600 = 4200
>
> Therefore, the sum must be composed of 7 numbers in
> that range.
>
>  x = 500 + 100*rand(1,7);
>  x = x * 4000/sum(x);
>
> John