Experimental Design
Vector 8:1, page 88
Transcribed from the printed issue; not yet reviewed. Read it in the PDF of the issue, page 88
APL is famed for conciseness. We all have favourite one-liners which require many lines in other languages. In this article we discuss a line which, from a practical point of view, solves not just an isolated problem but an entire subject, that of creating orthogonal experimental designs. This subject has given rise to a very large literature of which we recommend the excellent book Quality Through Design [1].
The Formula¶
I help produce longer lasting batteries. There are a surprisingly large number of parameters that can be varied in the design of a battery. Suppose we want to test X parameters to find how these affect performance, and decide to test PI values of the Ith parameter I = 1 … X. To do this we make N batteries and test their performance. The question is then how to vary the parameters for each battery to get the most information. Let F1, F2 … FK be the prime factors of N. N=F1 × F2 × … × FK. Let D1, D2 … DX be vectors of dimension K which define the design of our experiment. The one-liner mentioned above defines the values YI of the Ith parameter so that for the Jth battery the Ith parameter has the value YI[J].
If F ← F1,F2, … FK, then in APL2 we have:
Let P←P1, … PK, D and Y be the matrices defined by D[I;]←DI and Y[I;]←YI for I=1 … X then clearly:
For example if N←8, F←3⍴2, X←4, P←4⍴2, ⎕IO←0 the following matrix D produces the matrix Y:
Values Y of parameters being
Design tested for battery number
Parameter matrix D 1 2 3 4 5 6 7 8
--------------------------------------------------
1 1 0 0 0 0 0 0 1 1 1 1
2 0 1 0 0 0 1 1 0 0 1 1
3 0 0 1 0 1 0 1 0 1 0 1
4 1 1 1 0 1 1 0 1 0 0 1
Thus for example 0 0 0 0 1 1 1 1 is given by ,2|8|(1×⍳2)∘.+(0×⍳2)∘.+(0×⍳2). For the first battery all the parameters have the value 0, for the second the first two parameters have the value 0 and the second two 1 and so on, where 0 and 1 represent the two values being tested.
A Notation¶
I use a shorthand notation for these designs. Rank the prime factors of N in order of ascending magnitude e.g. if N=36 then the factors are 2 2 3 3. In this case K=4 as there are 4 prime factors. Let A be the vector K↑1, B be K↑0 1, C be the vector K↑0 0 1 and so on. Then put the A B C variables together so that for example ABC is the vector K↑(1,1,1) and AAAB is the vector K↑(3,1,0). The above design which is the standard 2*4 design with 8 trials is defined by A,B,C,ABC.
Consider for example a 5*3 design with 25 batteries. The design given by A,B,AAAABB can be represented by a Latin Square where the first parameter being tested goes from 0 to 4 along the Y axis (⎕IO←0) the second parameter from 0 to 4 along the X axis and the values of the third parameter are given by the table:
The A B C notation gives a way of classifying designs. A table of good designs can be constructed. This then gives a compact way of representing designs without pages of figures that are Y values.
number of number of values factors for
batteries of parameters best design
------------------------------------------------------
8 2 2 2 2 A B C ABC
8 4 4 AAC BBBCC
9 3 3 3 3 A B AB ABB
18 3 3 3 ABB ACC ABC
25 5 5 5 A B AAAABB
36 2 2 2 2 3 3 A B ACD BCD C D
The Goodness of Design.¶
To construct a design for a given number of parameters and batteries it may be necessary to experiment with the factors A B C … until we find a good design. My system asks for the factors and then produces a number which is a measure of how good the design is. After a small amount of practice you find that the number of combinations which are sensible is very limited and almost any one produces a good design. There is often only one best design.
The information we require about the parameters are in the first instance the linear effects, that is how the output of the battery varies linearly with the value of the parameters. Secondly we are interested in the quadratic effects and so on. To give independent estimates of these effects we need firstly the correlations between the YI variables to be zero. Secondly to find independent estimates of the quadratic effects we need the correlation of the linear effects with the quadratic effects and then the quadratic effects with each other to be zero.
After taking away their means from Y1, Y2, Y3 … we need +/YI×YJ to be zero for all 1 ≤ I < J ≤ X then all of +/YI×YJ×JK to be zero and so on. The goodness of design is 1 if all the +/YI×YJ are zero, plus 1 if in addition all the +/YI×YJ×YK are zero, plus 1 if all the +/YI×YJ×YK×YL are zero and so on. That is we try to make interactions have as high an order as possible. The exact formula which I use is not given here as it needs more than one line of code. It gives a value 2 1 1 2 2.4 1.6 respectively for the six designs in the above table.
The formula with which we started gives integer values for Y. Whereas any give values are to be tested which may not even be evenly spaced. The integers are simply changed for the values to be tested. The goodness of design criterion is equally valid in this case. The design matrix Y is printed out for the chosen design and the quantities (+/YI×YJ)÷+/|YI×YJ, (+/YI×YJ×YK)÷+/|YI×YJ×YK and so on, where these are not zero. This gives information about interactions.
[1] N Logothetis and H P Wynn, Quality Through Design: Experimental Design, Off-Line Quality Control and Taguchi’s Contributions, Oxford University Press, 1989.