R/index.C.r

Defines functions index.C

Documented in index.C

index.C<-function(d,cl)
{
  ddist<-d
	d<-data.matrix(d)
	DU<-0
	r<-0
	for (i in 1:max(cl))
	{
	  t<-d[cl==i,cl==i]		
		n<-sum(cl==i)
		if (n>1)
		{
			DU=DU+sum(t)/2
		}
		r<-r+n*(n-1)/2
	}
	Dmin=sum(sort(ddist)[1:r])
	Dmax=sum(sort(ddist,decreasing = T)[1:r])
	if(Dmin==Dmax)
		result<-NA
	else
		result<-(DU-Dmin)/(Dmax-Dmin)
	result		
}

Try the clusterSim package in your browser

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

clusterSim documentation built on Sept. 30, 2024, 9:15 a.m.