public double[] marginalProbability(int x_i) {
		int n = potentials.chainLength();
		int k = potentials.numXValues();
		
		double[] result = new double[k+1];
		sum = 0;
		result[0] = 0;
				
		for (int v =1 ; v <= k ; v++) {
			result[v] = messageFactor2Node(x_i, x_i, v);
			if (x_i != 1) {
				// not the first one
				result[v] *= messageFactor2Node(n+x_i -1, x_i, v);
			}
			if (x_i != n) {
				result[v] *= messageFactor2Node(n+x_i, x_i, v);
				// not the last one
			}
			sum += result[v];
		}	
		// normalization
		for (int v =1 ; v <= k ; v++) {
			result[v] /= sum;
		}
		return result;
	}