calculating median
<p>can anyone provide me solution of how to find the median of the final cluster members that i have got in the below program....???</p>

<pre><code>package javaapplication;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;

import java.io.BufferedInputStream; // to read text file line by line

public class microclustering{
private static boolean contains(String target, String value)
{
   boolean result= true;
    for(int i=0; i&lt;value.length();i++){
            if(target.indexOf(value.charAt(i))== -1)
    {
        result=false;
        return result;
    }
    }

  //  System.out.println(count+"intersection "+a+b);
    return result;
}

private static String[] arragedata(String [] data,int i, int j)
{
    int length=data.length;
  String newdata [] =  new String[length-1];
  if(i==j)
      return data;
  if(j&lt;i)
  {
      int temp=j;
      j=i;
      i=temp;
  }
   int temp=0;
  for(int k=0;k&lt;data.length;k++)
  {

      if(k!=i &amp;&amp; k!=j)
      {

          newdata[temp]=data[k];
          temp++;
      }
      else
          if(k==i)
          {
              newdata[temp]=data[i]+","+data[j];
              temp++;
          }
  }
  return newdata;
}
private static int getIntersection(String a, String b, String []database)
{
   int count=0;
   boolean flag=true;
   String [] first = a.split(",");
   String [] second = b.split(",");
    for(int i=0; i&lt;database.length;i++)
    {
        for(int j=0;j&lt;first.length;j++)
            if (!contains(database[i],first[j]))
                flag=false;
        if(flag==true)
        for(int j=0;j&lt;second.length;j++)
            if (!contains(database[i],second[j]))
                flag=false;

        if(flag==true)
            count++;
        else
            flag=true;

    }

    return count;
}
private static int getUnion(String a, String b, String []database)
{
   int count=0;
      boolean flag=false;
   String [] first = a.split(",");
   String [] second = b.split(",");

       for(int i=0; i&lt;database.length;i++)
    {

           for(int j=0;j&lt;first.length;j++)
            if (contains(database[i],first[j]))
                flag=true;

        if(flag==false)
        for(int j=0;j&lt;second.length;j++)
            if (contains(database[i],second[j]))
                flag=true;

           if(flag==true)
        {
            count++;
            flag=false;
        }


    }

    return count;
}

    public static void main(String[] args) throws Exception{
        // TODO code application logic here
           String [] database = {"abcefo",  "acg",  "ei",  "acdeg",  "acegl",  "ej",  "abcefp",  "acd",  "acegm",  "acegn"};
           String [] data = {"ecabf", "cad", "cag", "ecag", "ca", "eca", "e"};
              String format1 = "###0.00" ;               

            DecimalFormat fm1 = new DecimalFormat( format1,new DecimalFormatSymbols(Locale.US));


           boolean flag=true;
  do{
           double threshold=0.5;      // set threshold = 0.5

           int min_i=-1,min_j=-1;
           float [][] output= new float[data.length][data.length];
           for(int i=0;i&lt;data.length;i++){
               for(int j=0;j&lt;data.length;j++)
               {
                   if(getUnion(data[i],data[j],database)!= 0){

                       int b=getIntersection(data[i],data[j],database);
                       int c=getUnion(data[i],data[j],database);
                    float a=((float)b)/((float)c);
                   output[i][j]=1-a;
                   if(i==j)
                       output[i][j]=0;

                   }



               }

           } System.out.print("  \t");
              for(int j=0;j&lt;data.length;j++)
               {
                   System.out.print(data[j]+"\t");
               }
           System.out.print("\n");
           for(int i=0;i&lt;data.length;i++)
           {
               System.out.print(data[i]+"\t");
               for(int j=0;j&lt;data.length;j++)
               {

               System.out.print(fm1.format(output[i][j])+"\t");

              if(output[i][j]&gt;0 &amp;&amp; output[i][j]&lt;=threshold)
               {
                   threshold=output[i][j];
                   min_i=i;
                   min_j=j;

               }  }
              System.out.print("\n");

              }

           if(min_i!=-1 &amp;&amp; min_j!=-1)
           {
               System.out.println("minimum distance"+output[min_i][min_j]+"\t");
                        try{
             data=arragedata(data,min_i,min_j);

           }catch(Exception e){
               e.printStackTrace();
               flag=false;
           }
           }
           else
               flag=false;
                             System.out.print("\n\n\n");
    }while(flag==true);
       }

}
</code></pre>

<p>this is my output:</p>

<pre><code>        ecabf   cad     cag     ecag    ca      eca     e
ecabf   0.00    1.00    1.00    1.00    0.75    0.67    0.75
cad     1.00    0.00    0.83    0.80    0.75    0.86    0.89
cag     1.00    0.83    0.00    0.20    0.38    0.43    0.56
ecag    1.00    0.80    0.20    0.00    0.50    0.33    0.50
ca      0.75    0.75    0.38    0.50    0.00    0.25    0.40
eca     0.67    0.86    0.43    0.33    0.25    0.00    0.25
e       0.75    0.89    0.56    0.50    0.40    0.25    0.00
minimum distance0.19999999



        ecabf   cad     cag,ecag        ca      eca     e
ecabf   0.00    1.00    1.00    0.75    0.67    0.75
cad     1.00    0.00    0.83    0.75    0.86    0.89
cag,ecag        1.00    0.83    0.00    0.50    0.43    0.56
ca      0.75    0.75    0.50    0.00    0.25    0.40
eca     0.67    0.86    0.43    0.25    0.00    0.25
e       0.75    0.89    0.56    0.40    0.25    0.00
minimum distance0.25



        ecabf   cad     cag,ecag        ca      eca,e
ecabf   0.00    1.00    1.00    0.75    0.75
cad     1.00    0.00    0.83    0.75    0.89
cag,ecag        1.00    0.83    0.00    0.50    0.56
ca      0.75    0.75    0.50    0.00    0.40
eca,e   0.75    0.89    0.56    0.40    0.00
minimum distance0.39999998



        ecabf   cad     cag,ecag        ca,eca,e
ecabf   0.00    1.00    1.00    0.80
cad     1.00    0.00    0.83    0.90
cag,ecag        1.00    0.83    0.00    0.60
ca,eca,e        0.80    0.90    0.60    0.00
</code></pre>

<p>i need median of ca,eca,e and ecag,cag...</p>
