Skip to content
Back to formatted view

Raw Message

Message-ID: <43421A4B.5080608@7d4.com>
Date: 2005-10-04T05:59:39Z
From: vincent@7d4.com
Subject: sampling vectors
In-Reply-To: <fca0140a7c6e0ddafffbc1519f87528d@earthlink.net>

Eric Pante a ??crit :

> Hello Listers,
> I am trying to sample a vector to create a new one of sample length, 
> witha  sum equal to the sum of the initial vector:
> initial = 10, 30, 10 (sum=50)
> sample example = 5, 35, 10 (sum=50) or 25, 15, 10  (sum=50), etc ...
> My problem is to control the sum, so it stays constant.

f0 = function()
{
s1 = 50;
for (i in 0:s1)
	{
	s2 = s1 - i;
	for (j in 0:s2)
		{
		s3 = s2 - j;
		print (c(i,j,s3));
		}
	}
}

(If I have well understood the question) ?
hih
Vincent