Logo Search packages:      
Sourcecode: jlha-utils version File versions  Download package

long org::jlhafrontend::JLHAFrontEnd::calEntropy ( long[]  ent  )  [inline, private]

calculate entropy length

Parameters:
ent distribution table
Returns:
estimate compreesed length

Definition at line 238 of file JLHAFrontEnd.java.

Referenced by createFile().

                                        {
        long N=0,ret=0;
        double Hs=0.0,dN,dA,dRet;
        int i;
        for (i=0 ; i<ent.length ; i++) {
            N += ent[i];
        }
        if (N<=0) {
            return 0;
        }
        dN = (double)N;
        for (i=0 ; i<ent.length ; i++) {
          if (ent[i]==0) {
              continue;
          }
          dA = ((double)(ent[i]));
          Hs += (dA/dN)*(Math.log(dN)-Math.log(dA))/(Math.log(256));
        }
        dRet = N*(Hs);
        ret = (long)dRet;
        return ret;
    }


Generated by  Doxygen 1.6.0   Back to index