R/distributions.R

Defines functions distributions

Documented in distributions

#' Distribution calculates the pre-selected distribution probabilities given in Task 5 of Lab 5.
#'
#'
#' @param task Select (1-4) task to calculate
#'
#' @return The result of the selected calculation
#' @export
#'
#' @examples
#' distributions(task=1) performs 8C4.
#' Returns 70
#'
distributions <- function(task=1) {
  if (task==1) { # Task 1 is choose
      return(choose(8, 4))
  } else if (task==2) { # Task 2 is poisson right tail
      return(1 - ppois(q=4, lambda = 2))
  } else if (task==3) { # Task 3 is negative binomial
      return(dnbinom(x=10,size=3,prob=0.4))
  } else if (task==4) { # Task 4 is binomial left tail
      return(pbinom(q=8, size=15, prob=0.4))
  }
}
matthewCmatt/MATH4753CARROLL documentation built on April 20, 2021, 7:25 p.m.