R/proxi_simple.R

Defines functions proxi_simple

proxi_simple<- function(dx0, var, pert, frec){
################### Proximity function (faster version)########################
# Input:  
# dx0: vector of dist. from one individual to the ind. of different clusters.
# var: geometric variabilities.
# pert: integer vector indicating the group each individual belongs to.
# frec: frequencies of pert
# Output: 
# phi: vector of proximities from one individual to each cluster.

n <- length(pert)
k<- max(pert)


dx0 <- dx0*dx0
phi <- matrix(0,k,1)

#frec <- tabulate(pert) # vector of frecuencies of individuals in each population


for (pob in 1:k){
    aux <- sum(dx0[pert==pob])
    phi[pob] <- aux/frec[pob] - var[pob]
}


return(phi)

}

Try the ICGE package in your browser

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

ICGE documentation built on Oct. 17, 2022, 5:10 p.m.