public InferSampler () {
            documentTypes = new ArrayList<Integer>();
            for (int type = 0; type < numTypes; type++) {
                documentTypes.add(type);
            }
            documentTopics = new ArrayList<Integer>();
            for (int topic = 0; topic < numTopics; topic++) {
                documentTopics.add(topic);
            }

            docTypeCounts = new int[numTypes];
            docTypeTopicCounts = new int[numTypes][numTopics];
            docTopicCounts = new int[numTopics];
            docWordTopicCounts = new int[numWords][numTopics];

            bestTopicForWord = new int[numWords];
            for (int word = 0; word < numWords; word++) {
                int bestTopic = -1;
                int count = 0;
                for (int topic = 0; topic < numTopics; topic++) {
                    if (wordTopicCounts[word][topic] > count) {
                        count = wordTopicCounts[word][topic];
                        bestTopic = topic;
                    }
                }
                if (bestTopic == -1) {
                    throw new IllegalStateException("No topic sampled.");
                }
                bestTopicForWord[word] = bestTopic;
            }

            bestTypeForTopic = new int[numTopics];
            for (int topic = 0; topic < numTopics; topic++) {
                int bestType = -1;
                int count = 0;
                for (int type = 0; type < numTypes; type++) {
                    if (typeTopicCounts[type][topic] > count) {
                        count = typeTopicCounts[type][topic];
                        bestType = type;
                    }
                }
                bestTypeForTopic[topic] = bestType;
            }
        }