Is there a way to return addition values besides the scalar result from the MonteCarloSimulation
? I've looked through the documentation and this example but don't see a way to do it.
My use case:
In make_simulator
I generate a GaussianVector using the generator, then do some processing on that vector and I want to return that value together with my result. It's like the "domain" to the "image" and I need both to do further calculations. Thanks!
There is no way to return more data from the output function. The MonteCarloSimulation
returns a list of results, where each result has only generator_snapshot
(a RNG) and output
(a float).
The function make_simulator
is supposed to only depend on the generator
is was given. So in theory, you could take the generator_snapshot
and call a function similar to your make_simulator
again, to recompute the Gaussian vector, image, or whatever else you like from the RNG. This might waste some computation time, but should always be possible.
There is also another way: the order of list of results returned by MonteCarloSimulation
exactly matches the order of calls that happen to make_simulator
So if you are careful with your bookkeeping, inside of make_simulator
you could append your extra data into a global list of "images". Then after Monte Carlo finishes, you would have e.g. 100 images an 100 simulation outputs, and you could zip()
them together.
In summary: there is no way to return more data from make_simulator
, but you can change your make_simulator
to copy any data it needs into somewhere you can grab it later.