In this article I want to give out a basic reusable infrastructure for quickly starting off with simulations and reporting the results.

I will give a step-by-step setup of simulations testbed using 4 different technologies:

- Excel Spreadsheets
- Excel VBA macro
- Python
- Matlab

I believe that the best way to learn something is to bring in an application (or example) in as soon as possible. So the layout of this article will be that I will describe a fictitious 'situation' and then I will go ahead and provide a step-by-step guide as how to model the 'situation' in computer tech (e.g. matlab, python,...).

The complete source code is available in Appendix A

## Problem Definition (Example)

Say there are 1000 students and each students is given a die (small cube with the numbers 1 to 6 marked in dots on the sides used in gambling). Each student will roll the die once and the teacher will note that value (the number of dots on the side facing up) of the roll. Now, we are interested in the average (or the expected value) of this process.

Note: This is a very simple example which might not make a lot of sense in real life, but this will show us how simulations are useful. You can later extend this example into more complicated ones like ones given in Monte Carlo Simulation & Analytical Hierarchy Process.

## Solution

To the problem given above we can take 3 approaches to get to the solution:

- Using the principals of probability and mathematics to get the expected value (average in our example) for the result.
- Gather 1000 students; give each one of them a die; get a teacher; ask each student to roll the die and have the teacher note the result in a notebook; then take the average of the 1000 results. Good luck!
**Using simulations**: Write a computer program that simulates 1000 students, the properties of a die roll & the teacher who keeps record of the dice rolls. Have the computer create the report result.

I will talk about solutions 1 and 2 briefly next, then I will work on solution 3 and give you different infrastructures for simulations.

## Comments

please help me, please write a ful matlab code am v poor in matlab

I am not sure what exactly the question is asking but I think I do get the general question. The question is: "how many customers will switch to eCommerce service in the future?"

The answer to this that you could use either markov chains or monte carlo but I would use monte carlo method. Mostly because you do not have repeating states (i.e. once a customer is an eCommerce service user then he stays there).

Now, the information you are providing in point 2 and 3 is important and it needs to be detailed. You need to come up with numbers (e.g. probability for people coming from source 1 and converting to eCommerce service...). Doing a thorough analysis of the input variables will also help you decide which method (monte carlo or markov chains) to choose to solve this problem.

I noticed you also do eCommerce which piqued my interest in a simulation problem and best approach to solving it:

1) Website needs to forecast future eCommerce conversions quantity

2) 6 Different traffic sources each w/ varying conversion performance

3) 4 unique content areas a site visitor can consume along their site traversal path

Given the combination of varying originating traffic source & content areas combinations, would it be appropriate to solve the problem with markov & monte carlo methods?

Your thoughts?

Thank you very much in advance for your response.

Just added the matlab source code for the dice rolling problem.

Matlab...most awaited...

RSS feed for comments to this post