data{ int n; //number of sample int N; //row dimension of input int H; //hidden dimension int M; //column dimension of input int x[N,M,n]; //matrix to be decomposed by A and B real alpha; //hyperparameter for gamma dist real beta; //hyperparameter for gamma dist } parameters{ matrix[N, H] A; //non-neg constraint matrix[H, M] B; //non-neg constraint } model{ matrix[N,M] AB; AB = A*B; //assuming prior is gamma distribution for(i in 1:N){ for(j in 1:H){ A[i,j] ~ gamma(alpha,beta); } } for(i in 1:H){ for(j in 1:M){ B[i,j] ~ gamma(alpha,beta); } } // for(i in 1:n){ for(j in 1:N){ for(k in 1:M){ target += poisson_lpmf(x[j,k] | AB[j,k]); } } // } }