Operating System: Manjaro Linux 17.1.6
Interface Version: rstan 2.17.3
Compiler/Toolkit: GCC 7.3.0
I usually uses pystan but because some reason I need to use rstan. Using code:
data {
int<lower=0> N; // samples
int<lower=0> P; // features
int<lower=0> K; // hidden variables
real<lower=0> y[N,P]; // target matrix
real<lower=0> exp_lambda; // parameter for exponential distribution of H
real<lower=0> dir_alpha; // parameter for dirichlet distribution of W
real<lower=0> a;
real<lower=0> b;
//real<lower=0> sigma;
}
transformed data{
vector<lower=0>[K] dir_alpha_vec;
for (k in 1:K){
dir_alpha_vec[k] = dir_alpha;
}
}
parameters{
simplex[K] W[N]; // W[N,K] basis matrix
vector<lower=0>[K] H[P]; // H[K,p] coefficient matrix
real<lower=0> sigma;
}
model{
for (n in 1:N) {
W[n] ~ dirichlet(dir_alpha_vec);
}
for ( p in 1:P) {
H[p] ~ exponential(exp_lambda);
}
sigma ~ inv_gamma(a,b);
for (n in 1:N){
for (p in 1:P){
target += normal_lpdf(y[n,p] | dot_product(W[n] , H[p]),sigma);
}
}
}
in rstan is much slower compared to pystan to decompose 100 x 10 matrix. Is there any idea why this is happen?