Skip to content

Latest commit

 

History

History
74 lines (43 loc) · 4.97 KB

4_moving_results.md

File metadata and controls

74 lines (43 loc) · 4.97 KB

Importing and Exporting Simulation Results

Overview

Simulation operates using the simple constructor :Data In , Data Out or Inputs -> Model -> Outputs. This section covers importing inputs, perhaps from a different department or external source and then exporting the results for consumption by the interested stakeholders.

Getting Started

How are simulation results organized?

Essentially all Monte-Carlo simulation results take the form of a 2 dimensional table consisting of Trials (rows) and Variables (columns). Each variable is a vector (column) of numbers in a specific order. The order is important because it is what maintains the correlation structure. For example, because of the ordered sequence, you could calculate the R2 or correlation using any 2 output vector or input vectors.

Another thing to keep in mind is that each trial is assigned an ID and the generated by pushing a set of inputs into a model and recording the results in a row. Below is an example of a simulation results for Revenue - Expenses = Profit [output].

Trial_ID Revenue Expenses Profit
1 $1000 $500 $500
2 $400 $700 $-300
3 $700 $500 $200
... ... ... ...

A simulation results table should contain inputs variables and output variables side by side. This is a good practice because in theory it allows you to reconstruct/validate the results. In all cases, the number of trials/rows, must be of consistent length for all inputs and outputs in the model. (i.e. A 1000 trials). Each trial should have a trial ID. You can easily generate a Trial ID vector using Trial_ID = collect(1:1000) and append the column to your results using hcat().

Using the SIPMath standard to organize simulation results

SIPMath and probability management are approaches that were popularized by Sam Savage in 2009. A SIP Is known technically as a stochastic information packet or vector. The basic idea behind SIPMath is that models can be simplified and broken out into submodels. Generally, the output of a submodel can be summarized as an output vector and saves a lot of the computing efforts required to rerun both models together side-by-side.

In the SIPmath Standard, uncertainties are communicated as data arrays called SIPs (Stochastic Information Packets). For example, the SIP representing the roll of a die would be expressed as thousands of outcomes, which could be stored in Excel or a database. The open SIPmath™ Standard enables legacy and future simulation models to communicate with each other, ushering in a new paradigm for enterprise risk management.

siplogo

The SIPMath standard can be consulted on the probabilitymanagement.org website

Importing Variables / Data.

Importing results from another model for use in your analysis is a core element in building shared/collaborative models. The goal is to leverage the expertise/existing models/knowledge residing in other parts of the organization into a new model.

In Julia, You can pretty much important thing you like with formats such as XML, JSON, CSV. Furthermore, most Internet data APIs will allow you to download either of these formats and gives you the ability to have an auto updating model. Though you can use anything available in Julia to import your data into a data frame, MC Hammer handles CSV the most efficiently. There are 2 basic ways to import data into your MCHammer monte-carlo model:

  1. using standard CSV tables. Julia's CSV package is quite an effective tool and converts a CSV table into a data frame. As mentioned, as long as you remember that the number of trials must be consistent, you can import almost any table from the Internet.

  2. using the SIPMath 2.0 CSV Standard. MCHammer provides several functions to do so.

To import from the SIPModeler tool (also available for free from ProbabilityManagement.org), we recommend using the importxlsip()

importxlsip

When importing data using the strict 2.0 standard from another environment, including R, Python or some other business/planning system, we recommend using the importsip() function instead.

importsip

Exporting results

Exporting results from a simulation built in Julia can also be done using either the standard CSV package or with the functions included in MC Hammer to export using the SIPMath standard. One of the main differences when working in a programmatic environment versus a spreadsheet is that the metadata needs to reside in a separate file first before it can be recombined in the final export format. To do so, we have created both a function for incorporating MetaData into your SIP library and one for exporting the simulation results.

Generating MetaData

genmeta

Exporting Results in the CSV SIPMath 2.0 standard.

sip2csv