docs: public void initialState(int K) {
          int i;
  
          int M = documents.length;
  
          // initialise count variables.
          word_topic_matrix = new int[V][K];
          nd = new int[M][K];
          nwsum = new int[K];
          ndsum = new int[M];
  
          // The z_i are are initialised to values in [1,K] to determine the
          // initial state of the Markov chain.
  
          z = new int[M][];
          for (int m = 0; m < M; m++) {
              int N = documents[m].length;
              z[m] = new int[N];
              for (int n = 0; n < N; n++) {
                  int topic = (int) (Math.random() * K);
                  z[m][n] = topic;
                  // number of instances of word i assigned to topic j
                  word_topic_matrix[documents[m][n]][topic]++;
                  // number of words in document i assigned to topic j.
                  nd[m][topic]++;
                  // total number of words assigned to topic j.
                  nwsum[topic]++;
              }
              // total number of words in document i
              ndsum[m] = N;
          }
      }