Re: [R] Random Integers

2007-02-25 Thread Paul Smith
 Is there an R function to generate random integers?  Thanks in advance.

For example, if you want 5 random integers from the sequence 1:50, you
can do the following:

sample(1:50,5)

Paul

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random Integers

2007-02-25 Thread Andy Fugard


On 25 Feb 2007, at 06:51, Anup Nandialath wrote:


 Is there an R function to generate random integers?  Thanks in  
 advance.

The package Random does what you want, but requires a net connection.

http://cran.r-project.org/src/contrib/Descriptions/random.html

This package provides an interface to the true random number service  
provided by the random.org website created by Mads Haahr. The  
random.org web service samples atmospheric noise via radio tuned to  
an unused broadcasting frequency together with a skew correction  
algorithm due to John von Neumann.

install.packages(random)
library(random)
?random

  randomNumbers(10,1,6,1)
V1
1   5
2   3
3   6
4   3
5   3
6   1
7   6
8   4
9   5
10  3

Andy

--
Andy Fugard, Postgraduate Research Student
Psychology (Room F15), The University of Edinburgh,
   7 George Square, Edinburgh EH8 9JZ, UK
Mobile: +44 (0)78 123 87190   http://www.possibly.me.uk

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random Integers

2007-02-25 Thread Charles Annis, P.E.
Sure.

rpois(n, lambda)

... will do it.  But you should tell us something about how you want your
numbers to be distributed, since rpois() produces integers having a Poisson
distribution.

Charles Annis, P.E.

[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  614-455-3265
http://www.StatisticalEngineering.com
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anup Nandialath
Sent: Sunday, February 25, 2007 1:51 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Random Integers

Hi all,

Is there an R function to generate random integers?  Thanks in advance.

Sincerely

Anup

 
-
Now that's room service! Choose from over 150,000 hotels 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random Integers

2007-02-25 Thread Alberto Vieira Ferreira Monteiro
Charles Annis, P.E. wrote:

 rpois(n, lambda)

 ... will do it.  But you should tell us something about how you want your
 numbers to be distributed, since rpois() produces integers having a Poisson
 distribution.

nitpick
rpois does not generate random _integers_, it generates random 
_natural numbers_.
/nitpick

The question should be more descriptive. Random is half of the things
we need to know, the other half is how deterministic you want your integers.

For example, if you want to generate random integers in such a way that
all integers have the same probability, then this can't be done. OTOH, if
you want to simulate random integers that distribute like integers appear
in Nature, then it's still not precise, but there are serious attempts 
to reproduce this behaviour. Check in the wikipedia (www.wikipedia.org)
those distributions: Zip's law, Zeta distribution, Benford's law, 
Zipf-Mandelbrot law. The problem is that all of them generate positive
random integers, but it's not difficult to extrapolate them to integers.

Alberto Monteiro

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Random Integers

2007-02-25 Thread Anup Nandialath
Thanks Andy, Alberto, Charles, Paul and Pierre. I needed to simulate a set of 
counts to test a poisson regression model. Therefore would the best option be 
as pointed use rpois(.,.)?

Sincerely

Anup

 
-

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.