GMM in ScalaStan - how to define "ordered" in ScalaStan?

Hi,

I looked into ScalaStan and it is a very nice and simple code, after a bit of code reading it was not really clear how to use “ordered” in ScalaStan.

For example, how could I translate this code below (from here) into ScalaStan ?

I think the only missing point here is how to use “ordered” in ScalaStan. I have not found any example for it, on github. Even though I have searched for it : https://github.com/cibotech/ScalaStan/search?q=ordered&unscoped_q=ordered

I am sure I could figure it out, but before I try to do so, is it possible to describe this GMM below using ScalaStan ? I think yes, but just to be on the safe side I am asking it here.

If it is possible that I would be very happy to go deeper into ScalaStan. I have the feeling that the strong type system will make it possible to write Stan code very easily. Even if I am a complete beginner :), I have hope that “the type may be with me”.

Cheers

Jozsef

data {
 int<lower = 0> N;
 vector[N] y;
}

parameters {
  ordered[2] mu;
  real<lower=0> sigma[2];
  real<lower=0, upper=1> theta;
}

model {
 sigma ~ normal(0, 2);
 mu ~ normal(0, 2);
 theta ~ beta(5, 5);
 for (n in 1:N)
   target += log_mix(theta,
                     normal_lpdf(y[n] | mu[1], sigma[1]),
                     normal_lpdf(y[n] | mu[2], sigma[2]));
}