Solved – R Difference between rbinom and sample

binomial distributionr

I'm trying to model a Roulette game where if you bet on red (out of red(18/37), black(18/37), green(1/37)) and if you the ball lands on red you win 1 dollar and if it doesn't you lose $1.
So in this case, is it a binomial distribution? Since there are only 2 outcomes from the gamblers perspective, red or not red.
If thats the case are these 2 R functions the same?

set.seed(3)
sample(c(0,1),100,replace=T,prob=c(19/37,18/37))    
rbinom(n = 100, size = 1, prob = 18/37) 

Best Answer

Yes they are. sample draws random samples from categorical distribution, while rbinom from binomial distribution. Categorical distribution with two classes is a generalization of Bernoulli distribution. Binomial distribution is a distribution of $n$ Bernoulli trials. If you had multiple trials and multiple categories, you'd use multinomial distribution.