LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2000, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 31 Jul 2000 10:15:16 -0400
Reply-To:     Jack Shoemaker <JShoemaker@ACCORDANT.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Shoemaker <JShoemaker@ACCORDANT.NET>
Subject:      Re: 10 random numbers
Comments: To: "djaustin@MY-DEJA.COM" <djaustin@MY-DEJA.COM>
Comments: cc: "Paige Miller (E-mail)" <paigem@kodak.com>
Content-Type: text/plain; charset="iso-8859-1"

Daren,

I don't think this is any different than Paige's original elegant solution. As you point out, given the constraint that the 10 numbers must sum to one, you are only left with 9 degrees of freedom (= 10 - 1). You just can't get round that fact. Your method also only has nine degrees of freedom since the final number is constrained by the sum of the previous 9.

I think you hit the major point on the head - there are only 9 degrees of freedom in this problem no matter what technique you use.

- Jack

-- Jack N Shoemaker / JShoemaker@Accordant.net Visit our patient communities at http://www.accordant.com or our corporate site http://www.accordant.net

-----Original Message----- From: djaustin@MY-DEJA.COM [mailto:djaustin@MY-DEJA.COM] Sent: Monday, July 31, 2000 4:30 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: 10 random numbers

In article <s97db2e3.004@mail.health.state.mo.us>, Frank Schiffel <SchifF@MAIL.HEALTH.STATE.MO.US> wrote: > but that's a different question. > > if you assume you are truly getting 10 random numbers, summing them, then dividing by the sum to get unity, then dividing each by that sum, the only dependence is the sum itself, which was generated randomly. now the question is, how much is that non-random? > > or are we making this too complicated again?

> Perhaps it would be easier to think theoretically if the question were rephrased > as "How can I randomly select one set of 10 numbers from all possible sets of 10 > numbers which sum to 1?".

I've been thinking about the problem this weekend.

The solution, which I have yet to see, is precisely this: how many ways can the intetval 0-1 be partitiones into 10.

To answer this in an _unbiased_ manner we can do the following.

Evidently there are NINE degrees of freedom (the tenth random number comes free).

Choose NINE random numbers in the interval 0-1. these represent the positions of the nine PARTITIONS of the interval (not the numbers themselves). Sorth them descending and subtract the first number from 1 (total sum), the second from the next partition and so on until you get to the last difference, voila! 10 random numbers whose sum is unity.

The scaling of ten numbers by their sum is biased because it introduces vastly greater variability into the random numbers above that of the method proposed:

AS an example the code below for 1000 simulations produces standard deviations of 0.01 for my method and 0.05 for the normalised sum method. I could probably work on the theory to get these number exactly.

The code below should run "as is" but I am new to SAS so forgive any inefficiencies.

To generalise to n random numbers summing to M set the loop to n and the total to M in data one and data two steps.

Kind regards,

Daren Austin Principal Biomathematician, GlaxoWellcome.

options nonotes;

%macro simulate(out=,nsim=); %let sim=1; data &out; run; %do %while(&sim<&nsim);

/**** submit data one and two for partition method ****/ data one; do i = 1 to 101; if i >1 then ran=ranuni(0); else ran=0; output; end; proc sort; by descending ran;

data two (keep=ranone); set one; retain total 1; ranone = total-ran; total = ran; * proc print; run;

/**** scaled sum method *****/

data three (keep =rantwo); array rndnos(10) ran1-ran10; do i=1 to 10; rndnos(i)=ranuni(0); end; total = sum(of ran1-ran10); do i=1 to 10; rantwo = rndnos(i)/total; output; end; * proc print; run;

/**** some stats to output ****/

proc means data=two noprint; output out=four std=stdev1 kurtosis=kurt1 skewness=skew1;

proc means data=three noprint; output out=five std=stdev2 kurtosis=kurt2 skewness=skew2;

data six; merge four five;

data &out (keep=stdev1 stdev2 kurt1 kurt2 skew1 skew2); set &out six; run;

%let sim=%eval(&sim+1); %end; %mend;

%simulate(out=summary,nsim=1000); proc univariate data=summary; var stdev1 stdev2; run;

Sent via Deja.com http://www.deja.com/ Before you buy.


Back to: Top of message | Previous page | Main SAS-L page