Link to home
Start Free TrialLog in
Avatar of dadadude
dadadude

asked on

Find Cluster representative

Hello,
I have a cluster C = [v1,v2,...,Vn] i am trying to find a Vector vi that can be the representative of that cluster, and i don't think that what i am doing is right, that's the pseudo code:
in the code:
I do the following:
For all vectors in C (i)
    sum = 0
     For all vectors in C (j)
            sum+ = d(vi,vj);
   // add distance and vector to a list
   list.add(d)

find the vector with the minimum distance. Is that wrong?
thank you
List<Values> distance = new List<Values>();
        for (int i = 0; i < tab.Count; i++)
        {
            double sum = 0.0;  
            for (int j = 0; j < tab.Count; j++)
            {
               //tab[i] and tab[j] are 2 vectors
                sum += ManhattanDistance(tab[i],tab[j]);
                
            }
            distance.Add(new Values(tab[i],sum));
        }//end for
        distance.Sort(Values.CompareCarSpecs);
        return distance[0].Vector;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial