s-news
[Top] [All Lists]

Re: Question about random number generation in a user defined

To: "'Overstreet, Jason (FL51)'" <Jason.Overstreet@honeywell.com>
Subject: Re: Question about random number generation in a user defined
From: David L Lorenz <lorenz@usgs.gov>
Date: Thu, 22 Dec 2005 13:07:20 -0600
Cc: s-news@lists.biostat.wustl.edu, s-news-owner@lists.biostat.wustl.edu
In-reply-to: <E7D5AB4811D20B489622AABA9C53859109DAD614@teal-exch.amgen.com>

Jason,
  You can convert it to a matrix or array also:

x <- matrix(sample( 0:4, 100, replace=TRUE), ncol=10)

  The documentation on sample should indicate that the probability of selection for each value can be specified if you want.
Dave



"Austin, Matt" <maustin@amgen.com>
Sent by: s-news-owner@lists.biostat.wustl.edu

12/22/2005 01:00 PM

To
"'Overstreet, Jason (FL51)'" <Jason.Overstreet@honeywell.com>, s-news@lists.biostat.wustl.edu
cc
Subject
Re: [S] Question about random number generation in a user defined





If I'm understanding what you need, I think sample() would do what you want.
 
x <- sample( 0:4, 100, replace=TRUE)
 
Check ?sample for all the options.
 
--Matt
 
-----Original Message-----
From:
s-news-owner@lists.biostat.wustl.edu [mailto:s-news-owner@lists.biostat.wustl.edu]On Behalf Of Overstreet, Jason (FL51)
Sent:
Thursday, December 22, 2005 10:39 AM
To:
s-news@lists.biostat.wustl.edu
Subject:
[S] Question about random number generation in a user defined functio n

If you run this function you will randomly have an output of 0, 1, 2, 3, or 4.  

What I would like to know how to do is to:
1)Have this function run 100 times (really 10,000) independently
2) the output of each interation assigned as elements in an array.  

I am thinking that some sort of a loop is mandatory in this situation.  

Any pointers?

<<ET1.ssc>>

Jason Overstreet
Statistician

Honeywell DSES

(727) 539-3964

<Prev in Thread] Current Thread [Next in Thread>