R/shannon.R

Defines functions shannon

Documented in shannon

#' @title Shannon Entropy
#'
#' @description
#' Calculates the Shannon entropy value
#'
#' @param  p A vector of epiallele probabilities

#' @return The Shannon entropy value
#' @examples
#' a<-c(rep(0,13),60.86960,0.00000,39.1304)
#' shannon(a)
#' @export
shannon <- function(p) {
    p1 <- p[p > 0]
    sum(-p1/100 * log(p1/100))
}

Try the epihet package in your browser

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

epihet documentation built on Dec. 31, 2020, 2:01 a.m.