void mstep(MatrixDouble data) {
        int n, k, m;

        //Reset means to zero
        for (k = 0; k < numClusters; k++) {
            for (n = 0; n < numInputDimensions; n++) {
                clusters.set(0.0, k, n);
            }
        }

        //Get new mean by adding assigned data points and dividing by the number of values in each cluster
        for (m = 0; m < numTrainingSamples; m++) {
            for (n = 0; n < numInputDimensions; n++) {
                double val = clusters.get(assign[m], n);
                val += data.get(m, n);
                clusters.set(val, assign[m], n);
            }
        }

        for (k = 0; k < numClusters; k++) {
            if (count[k] > 0) {
                for (n = 0; n < numInputDimensions; n++) {
                    double val = clusters.get(k, n);
                    val /= (double) count[k];
                    clusters.set(val, k, n);
                }
            }
        }
    }