Simulation from discrete uniform

5 messages
Open this post in threaded view
|

Simulation from discrete uniform

 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Simulation from discrete uniform

 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 <[hidden email]>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]] > > ______________________________________________ > [hidden email] 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

Re: Simulation from discrete uniform

 In reply to this post by cassie jones ?sample -----Oprindelig meddelelse----- Fra: [hidden email] [mailto:[hidden email]] På vegne af cassie jones Sendt: 8. april 2011 03:16 Til: [hidden email] Emne: [R] Simulation from discrete uniform 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.