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 <cassiejone...@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@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