s-news
[Top] [All Lists]

runif function and extreme values:

To: s-news <s-news@wubios.wustl.edu>
Subject: runif function and extreme values:
From: Aldi Kraja <aldi@wubios.wustl.edu>
Date: Thu, 24 Oct 2002 15:35:25 -0500
Organization: Washington University
Reply-to: aldi@wubios.wustl.edu
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0
Thanks to all who responded: Rossini, Connor, Alzola, Plate, Lucke, McKinney
The problem was with the range I was creating by using the round function.
0.5-6.5

Also an interesting idea was given by Lucke:

You are not simulating a six-sided die.  You are sampling a continuous distribution.  Use sample(1:6,size=n,replace=T). Your extremes are diminished because of distribution truncation at 1 and 6. 

McKinney provided a detailed solution:
"rollingADie"<-
function(n, max1)
{
	# n nr. of obs. and max represent max number selected of a rolling die
	y <- sample(1:max1, size = n, replace = T)
	hist(y, main = "The rolling die", probability = T)
	return(NULL)
}

set.seed(123)
rollingADie(100000,6)
Thanks again,
Aldi
-- 

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