# Monte Carlo Scenarios

**URL:** <https://forum.mimiframework.org/t/monte-carlo-scenarios/123>\
**Category:** Uncategorized\
**Created:** [August 11, 2020, 5:08pm UTC](https://forum.mimiframework.org/t/monte-carlo-scenarios/123 "2020-08-11T17:08:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [August 11, 2020, 5:08pm UTC](https://forum.mimiframework.org/t/monte-carlo-scenarios/123/1 "2020-08-11T17:08:07Z")

</div>

From Catherine Ledna: Hi all, I have a quick question/request regarding some Mimi functionality. I’ve been doing Monte Carlo runs that are structured where I am updating an external model parameter for each model run. As a result, this means I’m calling the Mimi `run` function in a loop, with one Monte Carlo sample per run. Currently, the `run` function gives you the option to save Montecarlo parameters to a file, but only if all of the trials are run at once. If you’re calling run multiple times, it will overwrite the trial output filename unless a new file name is specified. I’m wondering if there is some way to modify that function to append to an existing parameter file rather than overwrite it. The only workaround I have currently is stitching a bunch of CSV files together after the fact, but it’s not very efficient. Thank you!

---

<div class="post-metadata">

**Author:** ![lrennels](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.mimiframework.org/lrennels/32/6_2.png) [@lrennels](https://forum.mimiframework.org/u/lrennels)\
**Post date:** [August 11, 2020, 6:39pm UTC](https://forum.mimiframework.org/t/monte-carlo-scenarios/123/2 "2020-08-11T18:39:06Z")

</div>

Hi there! Just to try to understand your problem a little bit better, am I right in saying that you have defined a `SimulationDefinition` using `@defsim`, let’s call it `sd`, and you are calling `run(sd, ...)` within your loop using a sample size of 1? And then also within that loop you are manually updating another external parameter?

Is there a reason that that external parameter can’t be given a distribution? We have the ability to run scenarios, which for example has been used to calculate the SCC for a few pre-defined discount rates, but that includes having maybe 3 scenarios for different discount rates, and then each is run for an N of 1000 or something, so I’m just trying to understand the case of only having a sample size of 1.

We can also talk offline if you aren’t comfortable posting code here!
