R/spinner_likelihoods.R

Defines functions spinner_likelihoods

Documented in spinner_likelihoods

spinner_likelihoods <- function(regions){
  # regions is a list of vectors
  # each vector is a set of spinner areas
  # output is the likelhood matrix, each row corresponds to a spinner
  N <- length(regions)
  n <- max(do.call(rbind, lapply(regions, length)))
  likelihood <- matrix(0, N, n)
  for (j in 1:N){
    nj <- length(regions[[j]])
    likelihood[j, 1:nj] <- regions[[j]] / sum(regions[[j]])
  }
  Letters <- c("A", "B", "C", "D", "E",
               "F", "G", "H", "I", "J")
  dimnames(likelihood)[[1]] <- paste("Spinner", Letters[1:N])
  dimnames(likelihood)[[2]] <- 1:n
  likelihood
}

Try the ProbBayes package in your browser

Any scripts or data that you put into this service are public.

ProbBayes documentation built on March 13, 2020, 1:31 a.m.