Hi Serdar,

Take a look at the following:

> sample(0:9, 100, replace = FALSE)
Error in sample(0:9, 100, replace = FALSE) :
  cannot take a sample larger than the population when 'replace = FALSE'
> sample(0:9, 100, replace = TRUE)
  [1] 5 6 5 7 3 0 8 4 8 2 2 4 7 6 0 7 0 0 0 7 5 6 3 6 0 9 6 1 2 6 9 0 0 4 7
9 8 6 4 7 0
 [42] 4 6 1 8 2 5 6 3 6 5 1 7 6 0 9 5 5 3 6 3 8 7 5 1 2 3 6 6 9 3 6 5 6 2 5
9 3 6 5 0 7
 [83] 8 0 8 7 3 9 9 1 4 4 1 1 0 9 8 1 9 3

HTH,
Jorge


On Sun, May 29, 2011 at 6:38 PM, SERDAR NESLIHANOGLU <> wrote:

> Hi
>
> Also , same problem to create discrete uniform Distribution ,
>
> But  sample () and  runif()  not useful to generate  discrete uniform .
>
> Ex:
>
>
> > u<-round(runif(10*10,min=1,max=10),0)
>
> > table(u)
>
> u
>
>  1 2 3 4 5 6 7 8 9 10
>
>  6 10  9 10 14  6 11 14 12  8
>
>
>
> Not useful for large number
>
>
> OR
>
> # for generate large number
>
>
> dus <- sample(0:9, 100, replace = FALSE)
>
> Error in base::sample(x, size, replace = replace, prob = prob, ...) :
>
>  cannot take a sample larger than the population when 'replace = FALSE'
>
>
> #### DO you have any suggestion my question ?
>
>
> Need to generate 1000*10 number from 1:250 with discrete uniform
> distribution ?
>
>
> Regards,
>
> Serdar
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@r-project.org 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.
>

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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.

Reply via email to