YouTip LogoYouTip

R Func Rbinom

# Distribution of the number of heads print("Frequency table of the number of heads:") print(table(coin_flips)) # dbinom: Probability of getting exactly 6 heads in 10 coin tosses prob_6 <- dbinom(6, size = 10, prob = 0.5) print(paste("Probability of exactly 6 heads:", round(prob_6, 4)))

Executing the above code produces the following output:

 "Before 10 number of heads:"
  5 7 8 4 5 6 5 7 6 2
 "Frequency table of the number of heads:"

 0  1  2  3  4  5  6  7  8  9 10 
 1  1  1  9 11 17 24 22  8  5  1 
 "Probability of exactly 6 heads: 0.2051"

Image 4: R Language Examples R Language Examples

← R Func Read TableR Func Range β†’