Map_rect and future Stan - any chance it gets easier? :)


So I have a big for loop with many many dependencies, packing them all into the current map_rect format is not something I’m in a hurry to do. Just wondering what, if anything, might be coming down the pipeline – is there any chance this sort of thing gets easier? I guess allowing arbitrary function structure, or allowing references to the general stan model environment from within the function and automagically determining the bits to pass out with map_rect, are the kind of things I’d enjoy very much ;)


Let’s hope so! We try to start by rolling out the most primitive form that’s workable and then see what we need after that.

I discussed one enhancement in my whirlwind roadmap talk at StanCon Helsinki :-) I suggested we can do something like this:

map_rect(f, theta, phi1, ..., phiJ, x1, ..., xM)

      = append_col(f(theta[1], phi1, ..., phiJ, x1[n], ..., xM[n])
                   f(theta[N], phi1, ..., phiJ, x1[n], ..., xM[n])

Where you can add arbitrary many parallel arrays after the main argument theta and shared arguments phi1, …, phiN., and where the data args can be real or floating point.

Part of what will make map_rect easier is ragged data structures, which is an independent ehancement from variadic arguments.