Results from playing with periodic models

Hmm, yes, let’s say you separate the amplitude and the phase angle

parameters{
  vector[2] phamp ;
}
transformed parameters{
  real amp = sqrt(dot_self(phamp));
  real phase = atan2(phamp[1],phamp[2]);

  vector[n] f = amp * P(x_times_pi_times_2*hz - phase) ;
}

Although atan2 is discontinuous at some point the important thing is that f is a smooth function of phamp. The original problem was the real<lower=0,upper=2*pi()> or even unit_vector[2] parametrization is discontinuous.
Separate sine and cosine terms was just a cute optimization for sin(x + atan2(v[1],v[2])).

2 Likes