R/lnq.R

Defines functions lnq.CommunityProfile lnq

Documented in lnq lnq.CommunityProfile

lnq <-
function(x, q)
{
  if (q == 1) {
    return (log(x))
  } else {
    Log <- (x^(1-q)-1)/(1-q)
    Log[x < 0] <- NA
    return (Log)
  }
}


lnq.CommunityProfile <-
function(Profile)
{
  if (!is.CommunityProfile(Profile))
    stop("Profile must be a CommunityProfile")
  
  CP <- Profile
  CP$y <- vapply(seq_len(length(CP$x)), function(i) lnq(CP$y[i], CP$x[i]), 0)
  if (!is.null(CP$low))
    CP$low <- vapply(seq_len(length(CP$x)), function(i) lnq(CP$low[i], CP$x[i]), 0)
  if (!is.null(CP$hi))
    CP$hi <- vapply(seq_len(length(CP$x)), function(i) lnq(CP$hi[i], CP$x[i]), 0)
  
  return (CP)
}

Try the entropart package in your browser

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

entropart documentation built on Sept. 26, 2023, 5:09 p.m.