PyMC3 Sampling with a model function that does not take array input natively

There’s some overview here that you might find useful: PyMC3 and Theano — PyMC3 3.11.5 documentation

In general, if you can reexpress your model in an “array-like” way that’s the easiest because Theano tried to follow Numpy API where possible. There are some cases like branching and looping that require special Theano constructors like Scan and IfElse.

If you really can’t express your function with Theano primitives you always have the option of wrapping arbitrary (deterministic) code in a Theano Op. This will become a black-box which Theano can’t introspect. The most direct limitations is that it becomes your responsibility to provide optimized code and gradient expressions (if you want to use something that needs it like NUTS)

There is a v3 version of this guide, but I didn’t bother to get its link: Using a “black box” likelihood function (numpy) — PyMC example gallery