Skip to content

Home / Monte Carlo / Model Building / Correlations / Correlations How-To

Correlations How-To

This walkthrough correlates the three part lengths of the stack-up model built in the Mark Input How-To, then adds a fourth input to show what a discrete input does to the dialog.

Work through that walkthrough first, or paste the worksheet below into a blank worksheet at cell A1 and mark B2, B3 and B4 as inputs before starting here, typing Base, Spacer and Cap in Input name. An input marked with no name is listed by the workbook name of its cell, if the cell has one, and otherwise by its cell address.

Sample Data

Part Length
Base 25
Spacer 12
Cap 8
Assembly =B2+B3+B4

Press Copy for Excel, click A1 and press Ctrl+V. The header row is copied too, so the headers land in row 1 and the four parts in rows 2 through 5.

The three parts are cut on the same machine from the same bar stock, so when one comes out long the others tend to come out long as well. That is what a correlation is for.

Make the first correlation

  1. Press QXL Monte Carlo > Design > Correlations.
  2. The list at the top is empty, and reads No correlations defined. with Click "Add Correlation" to create one. under it. The editor below it is greyed.
  3. Press Add Correlation. The editor comes alive and Name is filled in with Correlation 1.
  4. In Name, replace it with Bar stock.
  5. In Description, type All three parts cut from one bar. Nothing in the software reads this; it is your own note.
  6. In Inputs in this correlation, tick Base, Spacer and Cap.

The matrix appears as soon as the second box is ticked, and grows to three by three on the third. Its heading reads Rank correlation matrix (Spearman).

Fill in the matrix

The diagonal is fixed at 1 and cannot be typed in. Every pair you have not typed reads 0.

  1. Click the cell for Base and Spacer and type 0.6. The mirrored cell below the diagonal fills in by itself.
  2. In the cell for Base and Cap, type 0.5.
  3. In the cell for Spacer and Cap, type 0.4.
  4. Press Save correlation.

The row Bar stock (Gaussian, 3 inputs) appears in the list, and the semibold line under the grid goes away because there is nothing unsaved left.

Watch the lock arrive

  1. Change the Base and Spacer cell to 0.7.
  2. A semibold line appears under the grid:

Unsaved changes. Press Save correlation to keep them.

The list, Add Correlation and Delete Correlation are now all greyed. Save correlation and Discard changes are both live.

  1. Press Discard changes. You are asked first:

Discard the changes to "Bar stock"?

  1. Answer yes. The cell goes back to 0.6 and the lock lifts.

Clicking a list row never traps you. The lock arrives on your first change, not on the click, so you can always look at another correlation.

Ask for something impossible

Now type numbers that cannot all be true at once.

  1. Set the Base and Spacer cell to 0.95.
  2. Set the Base and Cap cell to 0.95.
  3. Set the Spacer and Cap cell to -0.9.
  4. Press Save correlation.

Base moves almost exactly with Spacer, and almost exactly with Cap. Two things that both move with Base cannot then move in opposition to each other, and the arithmetic will not allow it. A window opens:

Correlation group 1: The correlations are mathematically inconsistent in that the matrix is not positive semi-definite.

Quantum XL can replace these entries with the nearest correlation matrix that is mathematically consistent. The replacement values are placed in the grid for you to review before saving.

  1. Press Use the nearest valid correlations.

Nothing has been saved. The repaired numbers are now in the grid for you to look at, and the line under it says so:

The nearest valid correlations have been placed in the grid. Press Save correlation to keep them.

All three entries have moved. The repaired numbers are in the grid for you to review. What the replacement is guaranteed to satisfy is on Math Details.

  1. Press Save correlation to keep them, or Discard changes to go back to 0.6, 0.5 and 0.4. This walkthrough goes back, so press Discard changes and answer yes.

Pressing Keep my entries instead at step 5 leaves the grid exactly as you typed it and saves nothing, which is the plain refusal.

Try Clayton instead

Now look at a theta family.

  1. In Family, choose Clayton. Beside the dropdown:

Dependence is strongest at low values: low values of the inputs occur together more than high values do.

  1. The matrix and its heading disappear, and a Theta box appears with a Reflected row under it. Nothing was cleared: switch back to Gaussian and your three numbers are still there. Switch to Clayton again.
  2. Beside the theta box:

Theta is a finite number above 0. A larger theta ties the inputs more tightly; as theta nears 0 they become independent.

  1. Leave Theta empty and press Save correlation:

Theta is not a number.

  1. Type 0 and press Save correlation:

Correlation group 1: Clayton theta must be greater than zero.

  1. Type 2 and press Save correlation. It saves. One number covers all three inputs, which is the difference between a theta family and a matrix family.

Reflect one input

Under Reflected:

Reflected reverses the direction of an input's relationship.

There is one check box per ticked input.

  1. Tick the box for Cap.
  2. Press Save correlation.

Cap's relationship with Base and Spacer now runs the other way. A theta family has no matrix to put a minus sign in, so this is how it takes a negative relationship.

  1. Untick it and press Save correlation again. A correlation with nothing reflected is stored exactly as one written before the setting existed.

See what a Student-t asks for

  1. In Family, choose Student-t. The matrix comes back, and a Degrees of freedom box appears above it holding 5.

Like the Gaussian, with jointly extreme values more likely in both tails; fewer degrees of freedom make them more likely still.

  1. Clear the box and type 0, then press Save correlation:

Correlation group 1: Degrees of freedom must be a whole number of at least 1 (got 0).

  1. Put 5 back.

  2. Choose Gaussian again and press Save correlation.

Read a matrix off the worksheet

Typing a matrix by hand gets tedious past three inputs, so it can be read from cells.

Sample data for the range

1 0.6 0.5
0.6 1 0.4
0.5 0.4 1

The first row of that block is its header row, and the header row is copied along with the rest, so a paste aimed at A8 lands the three rows in A8:C10.

The steps

  1. Close the dialog with Done, press Copy for Excel above the block, click A8 and press Ctrl+V.
  2. Press Correlations again and select Bar stock.
  3. Press Read from Excel range and select A8:C10.
  4. The grid fills in.

The block has to be square, one row and one column per input:

The selected range is 3 by 4; it must be 3 by 3, one row and one column per input in the correlation.

Only the upper half is taken, but the lower half is checked. Change A9 from 0.6 to 0.65 and read the range again:

Cells for Base and Spacer disagree: 0.6 above the diagonal and 0.65 below it.

Nothing is quietly discarded. Change a diagonal cell away from 1 and the read is refused too, for the same reason: the grid's diagonal is fixed at 1, so a sheet saying otherwise disagrees with what would be saved.

An input belongs to one correlation only

  1. Press Add Correlation. The name fills in as Correlation 1, the first number no correlation in the workbook is using.
  2. Look at the checklist. Base, Spacer and Cap are all greyed, each reading in Bar stock.

There is nothing left to tick, so there is no second correlation to make from these three inputs. To move an input into a different group, take it out of the one that holds it first.

  1. Press Discard changes and answer yes. You are returned to the row that was selected before you pressed Add Correlation.

Add a discrete input

  1. Type 1 into B7 and Shim count into A7.
  2. Select B7 and press QXL Monte Carlo > Design > Mark Input.
  3. Type Shims in Input name, choose Uniform-Discrete, and set Lower to 0 and Upper to 3. Press OK.
  4. Press Correlations, select Bar stock, and tick Shims.

A line appears:

Shims is discrete. A correlated discrete input will not reach the requested correlation.

This is not a refusal. Fill in its matrix entries and it saves like any other.

Untick Shims. The correlation is back to what was saved, so Save correlation greys: there is nothing to save.

Delete it

  1. Select Bar stock in the list.
  2. Press Delete Correlation. You are asked first:

Delete "Bar stock"? This cannot be undone.

  1. Answer yes. The list is empty again, the editor greys, and the empty-list wording is back.

There is no undo, and there is no Cancel on this dialog to take the deletion back with, because every write happened at the moment its button was pressed.

Close it

Press Done, or press Escape, or use the window's own close box. All three ask about unsaved work first:

Save "name" before closing?

Answering yes runs the same save the button runs, refusals included.

See Also