This question is coding with R-Studio. Please write the code that would go into
ID: 3865472 • Letter: T
Question
This question is coding with R-Studio. Please write the code that would go into R-Studio for the answer for this question.
A whale sight-seeing company has determined that one whale will be spotted on average of every 4 hours. What is the Pr that at least one whale will be spotted in the fifth hour? If the company wanted to offer a 100% guarantee that customers will see at least one whale how long will the daily tours need to be?
Please write the code for R-Studio
Explanation / Answer
# file: whales.R whale_init = function(n) { result = list(data = c(1:n), n = n) return(result) } whale_rnd = function(n) { result = whale_init(n) result$data = sample(1:n) return(result) } whale_display = function(whale) { n = whale$n cat("# " ) for (i in 1:n) { cat(whale$data[i], " ", sep="") } cat("# ") } whale_succ = function(whale) { n = whale$n result = whale_init(n) result$data = whale$data left = n - 1 while (result$data[left] > result$data[left+1] && left >= 2) { left = left - 1 } if (left == 1 && result$data[left] > result$data[left+1]) { return(NULL) } right = n while (result$data[left] > result$data[right]) { right = right - 1 } tmp = result$data[left] result$data[left] = result$data[right] result$data[right] = tmp i = left + 1; j = n while (iRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.