public void calculateAllMarignals(){
		double[] x = new double[_m];
		double[] h = new double[_n];
		int[] nh1 = new int[_n]; // counts h==1
		
		for (int j=0; j<_n; j++)
			nh1[j] = 0;
		
		// initialize first x
		for (int i = 0; i<_m; i++)
			x[i] = (i+1)%2==0 ? 1 : 0;
		
		for (int t=0; t<this._num_samples; t++){
			// generate h, based on x
			for (int j=0; j<this._n; j++){
				double[] w_j = this.W_j(j);
				double xw_j = this.dotProd(x, w_j);
				double dj = this._parameters.hiddenBias(j+1);
				double phj1 = sigma(xw_j+dj);
				h[j] = this.randVal(phj1);
				if(h[j]==1)
					nh1[j]++;
			}
			
			// generate x, based on h
			for (int i=0; i<this._m; i++){
				double[] wi_ = this.Wi_(i);
				double hwi_ = this.dotProd(h, wi_);
				double bi = this._parameters.visibleBias(i+1);
				double pxi1 = sigma(hwi_+bi);
				x[i] = this.randVal(pxi1);
			}
		}
		
		for (int j=0; j<_n; j++)
			this._ph[j] = (nh1[j]+0.0) / this._num_samples;
	}