How does one type cast from real to int?
You cannot, see 3.2 in the manual.
One ad hoc option is to write your own convert function.
Nono, it might be possible to achieve a real to int cast in some way, but it’d break the autodiff if it were on a var. What are you trying to do with this?
It makes sense to do it with data where, e.g., you need a time measurement as a real but also need to index observation times. No sense in passing both in so I always keep a cast function around.
What exactly are you trying to do?
That’s not always true. The one case where we fail to support something reasonable is when you want to do some kind of interpolation. There, you often branch on the continuous parameters to make a discrete choice, but are then careful to make sure the discrete choices can still be differentiated.
Yeah that’s what I was getting at – shoulda been clearer. A dirt simple 1d interpolation function is something I’ve wanted in Stan a few times so I’m on the lookout for other people who want it.
You’re in a good position to implement one. There’s an interpolation function in BUGS that we’ve been meaning to implement for ages.