\(\(\( (*First\ we\ generate\ a\ 5\ variable\ of\ 100\ values\ Matrix*) \)\(
\)\(\(K = 
        DMGenMatrixEST[
          1000, "matrixGEN100.txt"];\)
 (*\ 
      DMGenMatrixEST\ function\ generates\ the\ values\ such\ that\ the\ variables\ are\ connected\ as\ \(\(follows\)\(:\)\)\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ ; \ \ \ \ \ \ \ \ \ \ \ \ \ 
a\  - \ Random; 
b\  - \ Random; 
c\  - \ 
        Random; 
d\  - \ 
        a\ AND\ b; 
e\  - \ 
        NOT\ a; 

So, \ 
for\ \(\(e\)\(:\)\)\ \ \ \ \ \ \ \ \ \ \ ; 
a\ and\ e\ are\ strongly\ correlated, \ 
      d\ and\ e\ are\ loosely\ correlated, 
\((b\ and\ c)\)\ are\ not\ correlated\ with\ e\ at\ \(\(all\)\(.\)\)

*) 

    \(tK\  = \ Transpose[K];\)\)\)\)

\(\(transK\  = \ tK;\)
 (*\ 
      The\ code\ assumes\ that\ the\ 5  
        th\ variable\ is\ the\ result\ variable, \ so, \ 
      in\ order\ to\ investigate\ let' s\ say\ "d", \ 
      we' re\ going\ to\ swap\ the\ 4  th\ with\ the\ 5  
        th\ \(\(one\)\(:\)\)\ *) 
\)
noOfVariables  =  Dimensions[
            transK][[1]];
  
possVals = {};
For[i = 1, 
      i <= noOfVariables,  i++, 
possVals  =  
          Append[possVals,  
            MDiffElementEST[transK, 
              i]];
]
  
probs  =  {};
\(For[i = 1, 
      i <= noOfVariables, \ \(i++\), 
\(probs\  = \ 
          Append[probs, \ 
            DMProbeEST[transK, i, 
              possVals[\([\)\(i\)\(]\)]]];\)
]
 (*\ 
      Designate\ the\ "e"\ variable\ as\ the\ result\ variable . \ 
          Calculate\ the\ Conditional\ Entropy\ for\ each\ of\ the\ remaining\ variable\ *) \)
condEntropy  =  {};
\(For[i = 1, 
      i < noOfVariables, \ \(i++\), 
\(condEntropy\  = \ 
          Append[condEntropy, \ 
            DMCondEntropyEST[transK, 5, i, possVals[\([\)\(i\)\(]\)], 
              possVals[\([\)\(5\)\(]\)], 
              probs[\([\)\(i\)\(]\)]]];\)
]
 (*\ 
      Calculate\ the\ Entropy\ for\ the\ "e"\ variable\ and\ subtract\ each\ of\ the\ remaining\ variables'\ Conditional\ Entropy\ wrt\ to\ the\ "e"\ variable\ to\ achieve\ the\ Information\ Gain\ vector\ "igain"\ *) \)
entE  =  
        DMEntropyEST[probs[[5]]];
igain  =  {}; 
For[i = 1, 
      i < noOfVariables,  i++, 
igain  =  
          Append[igain,  
            entE  -  
              condEntropy[[i]]];
]
 (* Now we can print the results *) 
For[i = 1, 
      i < noOfVariables,  i++, 
Print[ i, "\t", 
          N[ igain[[i]] ] ];
]

DMInfGainEST[tK, 
        5]  //  TableForm

(* 
      This works for the other variables as well: *) 
DMInfGainEST[tK, 4]  //  TableForm