@Override public double[] distributionForInstance(Instance x) throws Exception { // Start with a good guess int max = Utils.maxIndex(w); double y[] = h[max].distributionForInstance(x); double wm = A.product(h[max].probabilityForInstance(x,y)); for(int t = 0; t < m_Iy; t++) { // m ~ p(m|w) int m = A.samplePMF(w,m_R); // y ~ p(y|x,m) double y_[] = h[m].sampleForInstance(x,m_R); // <-- TODO: can do this faster, see #MCC // w = prod_j p(y[j]|x,m) double w_ = A.product(h[m].getConfidences()); // accept ? if (w_ > wm) { wm = w_; y = y_; } } return y; }
@Override public double[] distributionForInstance(Instance x) throws Exception { // Start with a good guess int max = Utils.maxIndex(w); double y[] = h[max].distributionForInstance(x); double wm = A.product(h[max].probabilityForInstance(x,y)); for(int t = 0; t < m_Iy; t++) { // m ~ p(m|w) int m = A.samplePMF(w,m_R); // y ~ p(y|x,m) double y_[] = h[m].sampleForInstance(x,m_R); // <-- TODO: can do this faster, see #MCC // w = prod_j p(y[j]|x,m) double w_ = A.product(h[m].getConfidences()); // accept ? if (w_ > wm) { wm = w_; y = y_; } } return y; }