Читать книгу Probability - Robert P. Dobrow - Страница 40
R: SIMULATING THE DIVISIBILITY PROBABILITY
Оглавление# Divisible356.R # simdivis() simulates one trial > simdivis <- function() { num <- sample(1:1000,1) if (num%%3==0 || num%%5==0 || num%%6==0) 1 else 0 } > simlist <- replicate(10000, simdivis()) mean(simlist) [1] 0.4707