# Understanding Monte Carlo Simulation with an Example

As someone who has collected and analyzed real data for a living, the idea of using simulated data for a Monte Carlo simulation sounds a bit odd. How can you improve a real product with simulated data? In this post, I’ll help you understand the methods behind Monte Carlo simulation and walk you through a simulation example using Companion by Minitab.

Companion by Minitab is a software platform that combines a desktop app for executing quality projects with a web dashboard that makes reporting on your entire quality initiative literally effortless. Among the first-in-class tools in the desktop app is a Monte Carlo simulation tool that makes this method extremely accessible.

## What Is Monte Carlo Simulation?

The Monte Carlo method uses repeated random sampling to generate simulated data to use with a mathematical model. This model often comes from a statistical analysis, such as a designed experiment or a regression analysis.

Suppose you study a process and use statistics to model it like this:

With this type of linear model, you can enter the process input values into the equation and predict the process output. However, in the real world, the input values won’t be a single value thanks to variability. Unfortunately, this input variability causes variability and defects in the output.

To design a better process, you could collect a mountain of data in order to determine how input variability relates to output variability under a variety of conditions. However, if you understand the typical distribution of the input values and you have an equation that models the process, you can easily generate a vast amount of simulated input values and enter them into the process equation to produce a simulated distribution of the process outputs.

You can also easily change these input distributions to answer "what if" types of questions. That's what Monte Carlo simulation is all about. In the example we are about to work through, we'll change both the mean and standard deviation of the simulated data to improve the quality of a product.

Today, simulated data is routinely used in situations where resources are limited or gathering real data would be too expensive or impractical.

With Companion by Minitab, engineers can easily perform a Monte Carlo analysis in order to:

• Simulate product results while accounting for the variability in the inputs
• Optimize process settings
• Identify critical-to-quality factors
• Find a solution to reduce defects

Along the way, Companion interprets simulation results and provides step-by-step guidance to help you find the best possible solution for reducing defects. I'll show you how to accomplish all of this right now!

## Step-by-Step Example of Monte Carlo Simulation

A materials engineer for a building products manufacturer is developing a new insulation product. The engineer performed an experiment and used statistics to analyze process factors that could impact the insulating effectiveness of the product. (The data for this DOE is just one of the many data set examples that can be found in Minitab’s Data Set Library.) For this Monte Carlo simulation example, we’ll use the regression equation shown above, which describes the statistically significant factors involved in the process.

Let's open Companion by Minitab's desktop app (if you don't already have it, you can try Companion free for 30 days). Open or start a new a project, then right-click on the project Roadmap™ to insert the Monte Carlo Simulation tool.

Step 1: Define the Process Inputs and Outputs

The first thing we need to do is to define the inputs and the distribution of their values. The process inputs are listed in the regression output and the engineer is familiar with the typical mean and standard deviation of each variable. For the output, we simply copy and paste the regression equation that describes the process from Minitab statistical software right into Companion's Monte Carlo tool!

When the Monte Carlo tool opens, we are presented with these entry fields:

It's an easy matter to enter the information about the inputs and outputs for the process as shown.

Verify your model with the above diagram and then click Simulate in the application ribbon.

Initial Simulation Results

After you click Simulate, Companion very quickly runs 50,000 simulations by default, though you can specify a higher or lower number of simulations.

Companion interprets the results for you using output that is typical for capability analysis—a capability histogram, percentage of defects, and the Ppk statistic. Companion correctly points out that our Ppk is below the generally accepted minimum value of Ppk.

Step-by-Step Guidance for the Monte Carlo Simulation

But Companion doesn’t just run the simulation and then let you figure what to do next. Instead, Companion has determined that our process is not satisfactory and presents you with a smart sequence of steps to improve the process capability.

How is it smart? Companion knows that it is generally easier to control the mean than the variability. Therefore, the next step that Companion presents is Parameter Optimization, which finds the mean settings that minimize the number of defects while still accounting for input variability.

Step 2: Define the Objective and Search Range for Parameter Optimization

At this stage, we want Companion to find an optimal combination of mean input settings to minimize defects. After you click Parameter Optimization, you'll need to specify your goal and use your process knowledge to define a reasonable search range for the input variables.

And, here are the simulation results!

At a glance, we can tell that the percentage of defects is way down. We can also see the optimal input settings in the table. However, our Ppk statistic is still below the generally accepted minimum value. Fortunately, Companion has a recommended next step to further improve the capability of our process.

Step 3: Control the Variability to Perform a Sensitivity Analysis

So far, we've improved the process by optimizing the mean input settings. That reduced defects greatly, but we still have more to do in the Monte Carlo simulation. Now, we need to reduce the variability in the process inputs in order to further reduce defects.

Reducing variability is typically more difficult. Consequently, you don't want to waste resources controlling the standard deviation for inputs that won't reduce the number defects. Fortunately, Companion includes an innovative graph that helps you identify the inputs where controlling the variability will produce the largest reductions in defects.

In this graph, look for inputs with sloped lines because reducing these standard deviations can reduce the variability in the output. Conversely, you can ease tolerances for inputs with a flat line because they don't affect the variability in the output.

In our graph, the slopes are fairly equal. Consequently, we'll try reducing the standard deviations of several inputs. You'll need to use process knowledge in order to identify realistic reductions. To change a setting, you can either click the points on the lines, or use the pull-down menu in the table.

Final Monte Carlo Simulation Results

Success! We've reduced the number of defects in our process and our Ppk statistic is 1.34, which is above the benchmark value. The assumptions table shows us the new settings and standard deviations for the process inputs that we should try. If we ran Parameter Optimization again, it would center the process and I'm sure we'd have even fewer defects.

To improve our process, Companion guided us on a smart sequence of steps during our Monte Carlo simulation:

1. Simulate the original process
2. Optimize the mean settings
3. Strategically reduce the variability

If you want to try Monte Carlo simulation for yourself, get the free trial of Companion by Minitab!