s-news
[Top] [All Lists]

FW: Question about random number generation in a user defined fun ctio n

To: s-news@lists.biostat.wustl.edu
Subject: FW: Question about random number generation in a user defined fun ctio n
From: "Overstreet, Jason (FL51)" <Jason.Overstreet@honeywell.com>
Date: Thu, 22 Dec 2005 12:13:38 -0700

Here is what the function looks like…

 

 

 

 

 

"ET1" <- function()

 

{

  

   ie1.1 <-punif(runif(1, min=0, max=1),min=0,max=1)

 

  

   be1 <- punif(runif(1, min=0, max=1),min=0,max=1)

   be2 <- punif(runif(1, min=0, max=1),min=0,max=1)

   be3 <- punif(runif(1, min=0, max=1),min=0,max=1)

   be4 <- punif(runif(1, min=0, max=1),min=0,max=1)

  

   if (ie1.1>.51) ie1.1 <- 0 else ie1.1 <- 1

  

   if (be1>.1) be1 <- 0 else be1 <- 1

   if (be2>.2) be2 <- 0 else be2 <- 1

   if (be3>.3) be3 <- 0 else be3 <- 1

   if (be4>.4) be4 <- 0 else be4 <- 1

  

  

   if (be1==1 && be2==1 ) TE1.1 <- 1 else TE1.1 <- 0

 

   if (be3==1 || be4==1 ) TE1.2 <- 1 else TE1.2 <- 0

      

   if (ie1.1==0) E1<-0

   if (ie1.1==1 && TE1.1==0 && TE1.2==0) E1<-1

   if (ie1.1==1 && TE1.1==0 && TE1.2==1) E1<-2

   if (ie1.1==1 && TE1.1==1 && TE1.2==0) E1<-3

   if (ie1.1==1 && TE1.1==1 && TE1.2==1) E1<-4

 

   return(E1)

 


From: Overstreet, Jason (FL51)
Sent: Thursday, December 22, 2005 1:39 PM
To: s-news@lists.biostat.wustl.edu
Subject: 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>
  • FW: Question about random number generation in a user defined fun ctio n, Overstreet, Jason (FL51) <=