[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Deborah Garvey" <DGarvey@scu.edu> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: - uniform() - random variable not uniformly distributed overinterval |

Date |
Wed, 09 Mar 2005 17:19:32 -0800 |

Dear listers: I am generating a random number with the goal of (randomly) assigning children who report multiple races to a single race category for purposes of analysis. I'd like to evenly distribute children across single race categories. However, when I use uniform() to generate a random number, I don't get an even split: . gen r = uniform() if k_race == 801 (363374 missing values generated) . su r Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- r | 2309 .4995691 .2914078 .0007709 .9993796 . gen byte k_race2 = . (365683 missing values generated) . replace k_race2 = 100 if r <= 0.5 (1151 real changes made) . replace k_race2 = 200 if r > 0.5 & r <= 1 k_race2 was byte now int (1158 real changes made) I am puzzled. I would expect median = mean = 0.5 for a uniform number defined over [0,1). This must be a simple, basic question, but neither changing the - set seed -, changing the interval to [0,1], or changing the observations selected seems to solve this problem. A search of on-line help, the list archives and the Stata FAQs didn't give me much insight either. Can you help me figure out what I'm doing wrong? Thanks, Deb Garvey ****************************** Deborah Garvey, Ph.D. Department of Economics Kenna Hall Santa Clara University Santa Clara, CA 95053 408/554-5580 408/554-2331 (FAX) dgarvey@scu.edu http://lsb.scu.edu/~dgarvey ********************************** This message scanned for viruses and SPAM by GWGuardian at SCU (MGW1) * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: - uniform() - random variable not uniformly distributed overinterval***From:*"Michael S. Hanson" <mshanson@mac.com>

**Re: st: - uniform() - random variable not uniformly distributed overinterval***From:*Richard Williams <Richard.A.Williams.5@nd.edu>

- Prev by Date:
**Re: st: Programing "by" and creating a new dataset** - Next by Date:
**Re: st: - uniform() - random variable not uniformlydistributed overinterval** - Previous by thread:
**st: Graphing curvilinear lines with moderators or interaction** - Next by thread:
**Re: st: - uniform() - random variable not uniformly distributed overinterval** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |