Naive classifier implementation

Thanks for the idea! Indeed I forgot to put a prior on the parameters mu_x and sigma_x. With some priors, the model blocks should look like:

model {
  for(dy in 1:D_y){
    mu_x[dy] ~ std_normal();
    sigma_x[dy] ~ gamma(2,0.1);
  }
  // likelihood functions
  ...                                              
}

For the likelihood function, the only obstacle is the declaration of unit simplex. Simplex is by definition a vector with constraints and indeed coded as such in stan. The constraints are not explicitly stated in the declaration, but they exist and are validated afterwards.
Therefore, I recall I heard from Andrew earlier that [Parser requires integer length for vector after supplying integer length - #2 by andrjohns]

Constraints aren’t used in the model block

The same problem persists even if the likelihood function is moved to the function block. To the best of my knowledge, declaration with constraints is allowed in the data, parameter and generated quantities blocks.
Indeed, when the declaration on theta_y (and the function should the likelihood function moved to the function block) is changed from simplex to vector, this code compiles now. Yet this voids the constraints on theta_y.

functions{
  vector naive_con(int D_y, int D_x_con,int N, array[] int y, matrix x_con,vector p_y,array[] vector mu_x,array[] vector sigma_x){
      vector[D_y] theta_y;                    // categorical probability
      array[D_y] vector[D_x_con] Lpx_y;        // log conditional probability
      vector[D_y] Lpxy;                        // marginal log likelihood
      for(n in 1:N){
        int dy;                                // conditioning on y level
        dy = y[n];
        for(dx in 1:D_x_con){
          Lpx_y[dy,dx] = normal_lpdf(x_con[n,dx] | mu_x[dy,dx], sigma_x[dy,dx]);    // calculate conditional probability
          // Lpx_y[dy] = normal_lpdf(x_con[n] | mu_x[dy], sigma_x[dy]);
        }
        Lpxy[dy] = log(p_y[dy]) + sum(Lpx_y[dy]);                                   // naive assumption of conditional independence
        theta_y[dy] = exp(Lpxy[dy] - sum(Lpxy));                                    // calculate posterior probability
      }
      return(theta_y);
  }
}

I am trying to come up with some post-declaration methods to constrain theta_y.