How much precission is required for custom p.d.f. to integrate to one in Stan?

I am in the process of writing a fairly complicated custom probability density function in Stan. The function is composed piece-wise like a spline, and it is impossible to get an integral of it with other means than by brute-force integration. The integral can’t be pre-computed, because it depends on the parameters.

I can approximate the integral using some form of interpolation techniques; the question arise: how precise the approximation needs to be.

The question is also cross-posted on CrossValidated. I will keep both threads in sync until I get an answer.

Are you worried about the precision of your integral just for the purpose of obtaining the normalization constant, or for some other reason?

Except for some very specific use cases, there’s no need to normalize probability density functions in Stan at all; see the _lupdf family of Stan functions.

2 Likes