@Override public double[] distributionForInstance(Instance xy) throws Exception { int L = xy.classIndex(); double y[] = new double[L]; double w = 0.0; /* * e.g. K = [3,3,5] * we push y_[] from [0,0,0] to [2,2,4] over all necessary iterations. */ int K[] = getKs(xy.dataset()); if (getDebug()) System.out.println("K[] = " + Arrays.toString(K)); double y_[] = new double[L]; for (int i = 0; i < 1000000; i++) { // limit to 1m // System.out.println(""+i+" "+Arrays.toString(y_)); double w_ = A.product(super.probabilityForInstance(xy, y_)); if (w_ > w) { if (getDebug()) System.out.println("y' = " + Arrays.toString(y_) + ", :" + w_); y = Arrays.copyOf(y_, y_.length); w = w_; } if (push(y_, K, 0)) { // Done ! if (getDebug()) System.out.println("Tried all " + (i + 1) + " combinations."); break; } } return y; }