Re: [R] Simulation from discrete uniform

From: Dennis Murphy <djmuser_at_gmail.com>
Date: Thu, 07 Apr 2011 20:16:23 -0700

Hi:

Suppose X has a discrete uniform distribution on the sample space S = {0, 1, 2, ..., 9}. Then a random sample of size 100 from this distribution, for example, would be

dus <- sample(0:9, 100, replace = TRUE)
# Checks:
table(dus)
lattice::barchart( ~ table(dus), xlim = c(0, 20))

The sample space comprises the first argument of sample(), the sample size is the second argument, and the replace = TRUE argument allows an element of the sample space to be selected more than once.

HTH,
Dennis

On Thu, Apr 7, 2011 at 6:15 PM, cassie jones <cassiejones26_at_gmail.com>wrote:

> Dear all,
>
> I am trying to simulate from discrete uniform distribution. But I could not
> find any in-built code in R. Could anyone help me please?
>
>
> Thanks in advance for the time and help.
>
>
>
>
> Cassie
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help_at_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_at_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. Received on Fri 08 Apr 2011 - 03:19:14 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 08 Apr 2011 - 04:20:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive