Take the integer part of a float in stan

I was just curious if there was a way to take the integer part of a float in stan. So if I have a number like 30.56 I can convert it to 30.

See the step functions. But note that if the quantity you’re transforming in this manner is a paramerter variable, the sampler is not going to perform well as steps in the parameter space induce infinite gradients. It could make sense if the quantity is data, but you will need to be sure the model is structured appropriately to account for the transform as a kind of measurement structure. And I don’t think it’s possible to make the result an int. If you really need that, and again if it’s data, best to do the transform outside of Stan.

1 Like