I’ve been tasked with creating a small demonstration for educational purposes of the Morris Screening Method but am having trouble implementing the trajectory design matrix in Mathematica. It’s a small example of 6 levels in 2 variables. The matrix should return a series of $ k+1$ perturbed $ {x_1, x_2}$ to use in the function of interest.

I feel like I’m close at the moment but after struggling yesterday I feel like I should now raise my hand and ask for Matrix help. I’m having trouble interpreting 1. $ x^*$ the matrix of random start points and 2. what the factorial increment diagonal matrix is. I can’t seem to get the dimensions right so it threads over the equation smoothly.

`ClearAll[RandDstar, TrajectoryMatrix] RandDstar := RandomChoice[{-1, 1}] TrajectoryMatrix[grid_] := Module[{r, b, x, JK, d, p, diff, \[CapitalDelta]}, b = LowerTriangularize[ConstantArray[1, {k + 1, k}]]; x = ConstantArray[RandomChoice[grid], k + 1]; d = LowerTriangularize[ConstantArray[RandDstar, {k + 1, k}]]; p = {{1, 0}, {0, 1}}; JK = ConstantArray[1, {k + 1, k}]; diff = First[Differences[grid[[;; 2, 2]]]]; \[CapitalDelta] = DiagonalMatrix[Table[diff, k + 1]]; (* Apply equation to matrixes to return b* *) (x + (\[CapitalDelta]/2 * (((2*b) - JK)*d) + JK))*p ] Block[{gridWorld, k = 2}, (*6 level Grid World with 2 variables *) gridWorld = Flatten[Table[{x, y}, {x, 0, 1, 0.2}, {y, 0, 1, 0.2}], 1]; TrajectoryMatrix[gridWorld] ] `