# Monte Carlo Analysis

## Description

Monte Carlo analysis allows you to perform multiple simulation runs with component values randomly varied across specified tolerances. The Simulator performs multiple passes of any of the standard analyses that are enabled (AC, DC Sweep, Operating Point, Transient, Transfer Function, Noise).

The Monte Carlo analysis can vary basic components and models - subcircuit data is not varied during the analysis.

## Setup

Monte Carlo analysis is set up on the **Monte Carlo Analysis Setup** page of the *Analyses Setup* dialog (after the dialog appears, click the **Monte Carlo Analysis** entry in the **Analyses/Options** list). An example setup for this analysis type is shown in the image below:

## Parameters

**Seed**- this value is used by the Simulator to generate random numbers for the various runs of the analysis. If you want to run a simulation with a different series of random numbers, this value must be changed to another number.`(Default = -1)`

.**Distribution**- this parameter defines the distribution of values obtained during random number generation. Three distribution types are available:

`Uniform`

(Default)

This is a flat distribution. Values are uniformly distributed over the specified tolerance range. For example, for a 1K resistor with a tolerance of 10%, there is an equal chance of the randomly generated value being anywhere between 900Ω and 1100Ω.

`Gaussian`

Values are distributed according to a Gaussian (bell-shaped) curve, with the center at the nominal value and the specified tolerance at +/- 3 standard deviations. For a resistor with a value of 1K +/- 10%, the center of the distribution would be at 1000Ω, +3 standard deviations is 1100Ω and -3 standard deviations is 990Ω.

With this type of distribution, there is a higher probability that the randomly generated value will be closer to the specified value.

`Worst Case`

This is the same as the Uniform distribution, but only the end points (worst case) of the range are used. For a 1K +/- 10% resistor, the value used would be randomly chosen from the two worst case values of 990Ω and 1100Ω. On any one simulation run there is an equal chance that the high-end worst case value (1100 Ω) or low-end worst case value (990 Ω) will be used.

**Number of Runs**- the number of simulation runs you want the Simulator to perform. Different device values will be used for each run, within the specified tolerance range. (Default = 5).**Default Resistor Tolerance**- the default tolerance to be observed for resistors. The value is entered as a percentage (Default = 10%).**Default Capacitor Tolerance**- the default tolerance to be observed for capacitors. The value is entered as a percentage (Default = 10%).**Default Inductor Tolerance**- the default tolerance to be observed for inductors. The value is entered as a percentage (Default = 10%).**Default Transistor Tolerance**- the default tolerance to be observed for transistors (beta forward). The value is entered as a percentage (Default = 10%).**Default DC Source Tolerance**- the default tolerance to be observed for DC Sources. The value is entered as a percentage (Default = 10%).**Default Digital Tp Tolerance**- the default tolerance to be observed for Digital Tp (propagation delay for digital devices). The value is entered as a percentage (Default = 10%).

The tolerance is used to determine the allowable range of values that can be generated by the random number generator for a device. For a device with nominal value**Val**, the range can be expressed as:_{Nom}

`ValNom - (Tolerance * ValNom) ≤ RANGE ≥ ValNom + (Tolerance * ValNom)`

**Specific Tolerances**- this parameter shows how many specific tolerances are currently defined. These are user-defined tolerances that are applied to specific components in the circuit. You can set up your own specific tolerances as required, by clicking the ... button to the right of the field. The*Monte Carlo - Specific Tolerances*dialog will appear. Specific tolerances that are defined will override the default tolerance settings. (Default = 0 defined).

## Defining Specific Tolerances

To define a new specific tolerance, click the **Add** button at the bottom of the Monte Carlo - Specific Tolerances dialog. A new row will be added, as shown in the image below:

In the **Designator** field, choose the component that the specific tolerance is to apply to, from the drop-down list. Include a parameter in the **Parameter** field if the device requires it. Supported parameters include: the `propagation delay`

of a digital component, the `Beta forward`

of a transistor and the `resistance`

of a potentiometer.

Each component can have two tolerances set: a **Device** tolerance and a **Lot** tolerance. Both device and lot tolerances are allowed, but only one is required. For a specific component, device and lot tolerances are calculated independently (using different random numbers) and then added together.

Set the **Tolerance** field to give the percentage tolerance for the component. The **Tracking No.** field is used to assign a common tracking number to components when you require the variation in their tolerance to be correlated. The **Distribution** field is used to specify the distribution type used for random number generation (`Uniform`

, `Gaussian`

or `Worst Case`

). If you give two components the same tracking number and device distribution then the same random number is used for both components when the device values for a simulation run are calculated.

Combined device and lot tolerances are useful where values are not completely correlated, but are not completely independent either. An example would be two different resistor packs. Here, the lot tolerance can be large (that is, the variation from wafer to wafer), while the device tolerance (the variation from resistor to resistor in the same package), is small. In this case the device tolerance should not be ignored because it may limit the overall performance of a circuit.

Consider the following example:

Assume R1 and R2 are both 1K, with a Device Tolerance of 1% (same Device Tracking number) and they have a Lot Tolerance of 4%, with the same Lot Tracking number.

For each Monte Carlo run the resistors are first assigned the same lot variation (a nominal value) between +/- 4%. Then each resistor is assigned a device tolerance between +/- 1%. This gives a total tolerance of 5% (1%

+ 4%). However, during the same run the values of each resistor cannot be any farther than +/- 1% from their nominal value, or 2% from each other.

## Notes

At least one of the standard analysis types (AC, DC Sweep, Operating Point, Transient, Transfer Function, Noise) must be enabled in order to perform a Monte Carlo analysis.

Data is saved for all signals in the **Available Signals** list, on the **General Setup** page of the *Analyses Setup* dialog.

Running a Monte Carlo analysis can result in a large amount of data being calculated. To limit the amount of data calculated, you can set the **Collect Data For** option on the **General Setup** page of the *Analyses Setup* dialog to **Active Signals**. With this option, data is only calculated for variables currently listed in the **Active Signals** list.

Each component is randomly varied independent of other components. For example, if a circuit has two 10 K resistors, and the default tolerance is set to 10%, then during the first pass of the simulation, one resistor might have a value of 953 Ω, and the other one could be 1022 Ω. The program uses a separate and independent random number to generate the value for each component.

As running a Monte Carlo analysis actually performs multiple passes of the enabled standard analyses, there is a special identifier used when displaying the waveforms in the Sim Data Editor's Waveform Analysis window. Each pass is identified by adding a letter and number as a suffix to the waveform name. For a Monte Carlo analysis, the letter used is m and the number used identifies which pass the waveform relates to (e.g. `Output_m1`

, `Output_m2`

, etc).

## Examples

Consider the circuit in the image above, where a Transient analysis is to be performed in conjunction with the use of the Monte Carlo analysis feature. The Transient analysis is defined with the following parameter values:

**Transient Start Time**=`0.000`

**Transient Stop Time**=`500.0u`

**Transient Step Time**=`2.000u`

**Transient Max Step Time**=`2.000u`

The Monte Carlo analysis is defined with the following parameter values:

**Seed**=`-1`

**Distribution**=`Uniform`

**Number of Runs**=`5`

**Default Resistor Tolerance**=`15%`

**Default Capacitor Tolerance**=`15%`

- All other parameters are left at their default values.

The entry in the SPICE netlist will be:

`*Selected Circuit Analyses:`

.TRAN 2E-6 0.0005 0 2E-6

.CONTROL

TOL C1 DEV=15% Uniform

TOL Q1[BF] DEV=10% Uniform

TOL Q2[BF] DEV=10% Uniform

TOL R1 DEV=15% Uniform

TOL R2 DEV=15% Uniform

TOL R3 DEV=15% Uniform

TOL R4 DEV=15% Uniform

TOL RL DEV=15% Uniform

TOL V1 DEV=10% Uniform

TOL VCC DEV=10% Uniform

TOL VSS DEV=10% Uniform

MC 5 SEED=-1

.ENDC

unning the simulation will yield standard waveforms for the IN and OUT signals. For the OUT signal, the following additional waveforms will be available in the **Source Data** region of the *Sim Data* panel, corresponding to the five runs performed as part of the Monte Carlo analysis.

`out_m1`

`out_m2`

`out_m3`

`out_m4`

`out_m5`

Simply make the wave plot containing the out signal active and double-click on each additional waveform to add it to the view. The default waveform (out) will also be generated for comparison.