Home / Monte Carlo / Additional Tools / Sampling Matrices / Sampling Matrices How-To
Sampling Matrices How-To¶
This walkthrough writes a sampling matrix, which is a plan you take away and run experiments against. It is not a simulation: it reads no model and needs no marked workbook.
Steps¶
-
QXL Monte Carlo New > Additional Tools > Sampling Matrices.
-
Ask for 3 factors and 20 cases, and choose Latin Hypercube Sampling.
-
Finish. A new worksheet appears holding the matrix.
What you get¶
Twenty rows and three columns, and every value strictly between 0 and 1. Neither endpoint is ever produced, which is what lets you put each value through an inverse distribution function on the sheet without it being handed a 0 or a 1.
Each column is a stratified sample. With twenty cases the interval is cut into twenty equal slices and each column takes exactly one point from each slice, so no region of the range is missed and none is sampled twice.
Check it yourself¶
Sort any column. The sorted values should land one in each twentieth: the first between 0 and 0.05, the second between 0.05 and 0.1, and so on. That is the stratification, and it is the property that separates this from twenty independent random numbers.
Every column is shuffled independently, so sorting one column does not order the others.
The twenty slices, to check a column against¶
This is the one thing about a sampling matrix that is fixed rather than random. The values change every time you generate one; the slices they have to fall into do not. Press Copy for Excel and paste the table into an empty part of the worksheet, beside a sorted column, and every row of the sorted column should sit between its Lower and Upper.
| Slice | Lower | Midpoint | Upper |
|---|---|---|---|
| 1 | 0.00 | 0.025 | 0.05 |
| 2 | 0.05 | 0.075 | 0.10 |
| 3 | 0.10 | 0.125 | 0.15 |
| 4 | 0.15 | 0.175 | 0.20 |
| 5 | 0.20 | 0.225 | 0.25 |
| 6 | 0.25 | 0.275 | 0.30 |
| 7 | 0.30 | 0.325 | 0.35 |
| 8 | 0.35 | 0.375 | 0.40 |
| 9 | 0.40 | 0.425 | 0.45 |
| 10 | 0.45 | 0.475 | 0.50 |
| 11 | 0.50 | 0.525 | 0.55 |
| 12 | 0.55 | 0.575 | 0.60 |
| 13 | 0.60 | 0.625 | 0.65 |
| 14 | 0.65 | 0.675 | 0.70 |
| 15 | 0.70 | 0.725 | 0.75 |
| 16 | 0.75 | 0.775 | 0.80 |
| 17 | 0.80 | 0.825 | 0.85 |
| 18 | 0.85 | 0.875 | 0.90 |
| 19 | 0.90 | 0.925 | 0.95 |
| 20 | 0.95 | 0.975 | 1.00 |
The Midpoint column is there for the comparison in the next section.
Now compare the methods¶
Build the same size again with Descriptive Sampling. The values in each column are now the slice midpoints, 0.025, 0.075 and so on, in a shuffled order: the set is fixed and only the order varies. Sort one and it is the Midpoint column above, top to bottom, exactly.
Then try Sobol. It refuses 20 and asks for a power of two, because one point per slice in every dimension holds at powers of two and not between them. Ask for 16 or 32 instead.
Things to try next¶
- Ask for 1 case, or 20001. Both are refused by name rather than quietly clamped.
- Put the values through
NORM.INVon the sheet to turn the matrix into settings in your own units. - Read Math Details for the three v17 defects that make an old matrix differ from a new one.
See Also¶
- Sampling Matrices
- Options, every control on the dialog
- Math Details