R/rbestdist.R

Defines functions rbestdist

Documented in rbestdist

rbestdist<-function(dist,r,penalty=NULL,beta=100){
  stopifnot(length(dist$d)==length(r))
  maxr=max(r)
  if (!is.null(penalty)) stopifnot(length(penalty)==maxr)
  if (is.null(penalty)){
    penalty=numeric(maxr)
    if (maxr>1){
      for (j in 2:maxr){
        penalty[j]=(1+penalty[j-1])*beta
      }
    }
  }
  fbpenalty=(1+penalty[maxr])*beta
  for (k in 1:maxr){
    dist$d[which(r==k)]=dist$d[which(r==k)]+penalty[k]
  }
  return(list(newdist=dist, fbpenalty=fbpenalty))
}

Try the RBestMatch package in your browser

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

RBestMatch documentation built on Dec. 21, 2021, 9:07 a.m.