On Thu, 2005-03-10 at 20:54 -0600, mirage sell wrote:
> Hi everyone, I need help.
> I want to have a "uniform" kind distribution. When I used sample function I 
> got almost twice many zeros compared to other numbers. What's wrong with my 
> command ?
> 
> temp <-sample(0:12, 2000, replace=T,prob=(rep(1/13,13)))
> hist(temp)
> 
> Thanks in advance,

Hint: take note that there are only 12 cells in the plot, not 13...

However, note that the frequency of the 13 elements are appropriate:

> table(sample(0:12, 2000, replace=T))

  0   1   2   3   4   5   6   7   8   9  10  11  12
158 156 151 163 156 158 146 154 134 158 146 147 173


Review the details of how the breaks are selected in ?hist.

BTW, you do not need to specify the 'prob' argument if you want equal
probabilities as per my example above.

HTH,

Marc Schwartz

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to