RE: [R] random number generation

About this list Date view Thread view Subject view Author view Attachment view

From: Adaikalavan Ramasamy (gisar@nus.edu.sg)
Date: Fri 03 Jan 2003 - 13:11:46 EST


Message-id: <024D6AEFCB92CB47BA1085751D184BB80105F1E2@MBXSRV03.stf.nus.edu.sg>

Many ways of doing this. Try rbinom(n=1, size=1, prob=0.5) and you can
adjust the 'prob' argument if you have an unfair coin. The other one is
sample( c(0,1), 1 ) which is a sampling method and also has a 'prob'
argument. Other functions include rnorm, runif, rpois ....

-----Original Message-----
From: Joshua Gramlich [mailto:jgramlich@piocon.com]
Sent: Friday, January 03, 2003 5:59 AM
To: r-help@stat.math.ethz.ch
Subject: [R] random number generation

Can a single random number be generated in R? I have an exercise that
wants to simulate coin tosses, and I cannot seem to find a good example
of the use of random number generation in R. Any help?

Joshua Gramlich
Chicago, IL

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
R-help@stat.math.ethz.ch mailing list
http://www.stat.math.ethz.ch/mailman/listinfo/r-help


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Tue 01 Jul 2003 - 09:11:18 EST