11.6 Map-rect function
Stan provides a higher-order map function. This allows map-reduce functionality to be coded in Stan as described in the user’s guide.
11.6.1 Specifying the mapped function
The function being mapped must have a signature identical to that of
f in the following declaration.
vector f(vector phi, vector theta, data array real x_r, data array int x_i);
The map function returns the sequence of results for the particular shard being evaluated. The arguments to the mapped function are:
phi, the sequence of parameters shared across shards
theta, the sequence of parameters specific to this shard
x_r, sequence of real-valued data
x_i, sequence of integer data
All input for the mapped function must be packed into these sequences and all output from the mapped function must be packed into a single vector. The vector of output from each mapped function is concatenated into the final result.
11.6.2 Rectangular map
The rectangular map function operates on rectangular (not ragged) data structures, with parallel data structures for job-specific parameters, job-specific real data, and job-specific integer data.
(F f, vector phi, array vector theta, data array[,] real x_r, data array[,] int x_i)
Return the concatenation of the results of applying the function f, of type
(vector, vector, array real, array int):vector elementwise, i.e.,
f(phi, theta[n], x_r[n], x_i[n]) for each
the size of the parallel arrays of job-specific/local parameters
theta, real data
x_r, and integer data
x_r. The shared/global
phi are passed to each invocation of
Available since 2.18