(*******************************************************************
This file was generated automatically by the Mathematica front end.
It contains Initialization cells from a Notebook file, which
typically will have the same name as this file except ending in
".nb" instead of ".m".

This file is intended to be loaded into the Mathematica kernel using
the package loading commands Get or Needs.  Doing so is equivalent
to using the Evaluate Initialization Cells menu command in the front
end.

DO NOT EDIT THIS FILE.  This entire file is regenerated
automatically each time the parent Notebook file is saved in the
Mathematica front end.  Any changes you make to this file will be
overwritten.
***********************************************************************)



randmat[n_, m_, \[Delta]_] :=
  
  Return[Table[Table[If[Random[] < \[Delta], 1, 0],{i, 1, m}], {j, 1, n}]]

condprobsr[a_, i_, j_, n_, m_] :=
  Return[a[[i,j]] /Sum[a[[k,j]], {k, 1, n}]]

combprob[a_, i_, j_, n_, m_] :=
  Return[(1/n)*condprobsr[a,i,j,n,m]]

wordprob[a_, i_, n_, m_] :=
  Return[Sum[combprob[a,i,j,n,m],{j,1,n}]]

HnS[a_,n_,m_] :=
  Return[-Sum[wordprob[a,i,n,m]*
          If[(wordprob[a,i,n,m]\[Equal]0), 0,Log[n, wordprob[a,i,n,m]]],
        {i, 1,n}]]

HmRsi[a_, i_, n_,m_] :=
  
  Return[-Sum[(combprob[a,i,j,n,m]/wordprob[a,i,n,m])*
          
          If[(combprob[a,i,j,n,m]/wordprob[a,i,n,m]\[Equal]0), 0, 
            Log[m,combprob[a,i,j,n,m]/wordprob[a,i,n,m]]],
        {j,1,m}]]

HmRs[a_,n_, m_] := 
  Return[Sum[wordprob[a,i,n,m]*HmRsi[a,i,n,m],{i,1,n}]]

\[CapitalOmega][\[Lambda]_, a_, n_, m_] :=
  
  Return[\[Lambda]*HmRs[a,n,m] + (1-\[Lambda])*HnS[a,n,m]]

jigglemat[a_, n_, m_, \[Nu]_] :=
  Block[{outputmat = a,
                    x,
                     y},
                   For[x = 1, x \[LessEqual] n, x++,
                              For[y = 1, y \[LessEqual] m, y++,
                                          If[(Random[] \[LessEqual] \[Nu]),
                                                     
              outputmat = 
                  ReplacePart[outputmat, 1 - outputmat[[x,y]], {x, y}];
                                               ];
                                         ];
                           ];
                 Return[outputmat]
               ]
























