LIBRARY OF THE MASSACHUSETTS INSTITUTE OF TECHNOLOGY J)tJU^ ALFRED P. WORKING PAPER SLOAN SCHOOL OF MANAGEMENT AN ISO-CONTOUR PLOTTING ROUTINE AS A TOOL FOR MAXIMUM LIKELIHOOD ESTIMATION RAFAEL C. June 1975 ANDREU WP 795-75 MASSACHUSETTS INSTITUTE OF TECHNOLOGY 50 MEMORIAL DRIVE CAMBRIDGE, MASSACHUSETTS 02139 MASS. INST. TECH. AUG G 75 DEWEY LIBRARY AN ISO-CONTOUR PLOTTING ROUTINE AS A TOOL FOR MAXIMUM LIKELIHOOD ESTIMATION RAFAEL C. June 1975 ANDREU WP 795-75 This Working Paper is part of Mr. Andreu's doctoral program at the MIT Sloan School of Management. HOI'S ryi.l.T. LIBRARIES AUG 6- 1975 RECEIVED 1-1 1.- Introduction. Dolnf^ maximum likelihood estimation when the like- lihood function is so complicated that it becomes very difficult to deal with it ajialytically ia a problem which has to be solved numerically. The process of estimating the parameters of an un- derlying lognormal distribution when sampling is considered to be without replacement and proportional to size constitutes one such case. This particular sampling process is being used as a model for inferring the distribution of yet undis- covered oil and gas deposits from a sample of discovered pools. Pool discovery (observing deposit sizes in order of discovery) "is more akin to sampling without replacement and proportional to size than to sampling values of independent, identically distributed random variables" (1). This feature had been ignored until recently. In addition, as it is also pointed out in (1), the population from which the discovery process picks pool sizes can be considered as a sequence of N values of N mutually in- dependent rajidom variables identically distributed with a common lognormal density, generated by nature. There is empirical evidence showing that a variety of actual size dis- tributions can be reasonably characterized as being lognormal. The mathematical analysis of sucha a sampling process is contained in (1), where an asymtotic expansion of the likelihood function (valid for large N and fixed sample ^724727 1-2 size n) is developed, since working with the exact expresions turns out to be very difficult. In turn, since this asymtotic expansion is analyti- cally complicated, to understajid its behavior we supplement the treatment of it in (1) with numerical analysis of parti- cular cases. Its complexity may be better understood by looking at its expresion. The expansion for the sampling density of Y, valid for large p = N-n isi n r / ^ ^T n X Y.f (Y . [e) ^N 'J {lt|pVg2(pMj^,Y) + ^P^V^g^(pMj^,Y) + p(|M^-^^M2+-3-Mj)g^(pMj^,Y) + ^) (p } where the functions g^(pMj^,Y) are given by g^(pMwY) = r (pM ,Y) = [ I (pM,+b ) + 2 I (pM,+b.)"^ + 1,3._ ^] +3[ I i=l ^ I ., .^ (pM,+b , (pM +b ) ^ ^, [ I (pM +b )"^]^, ,-l_ "-][ ) V' I .-2. „ (pM.+b.)"'^] , + 3[ I (pM +b.)"l]^[ j=l ^ " n - + 3[ I (pM^+b + 6[ j=l - I (pM +b j=l "• (pM,+b.)"2] I i=l ) 3 -^ n -, ^]^ + 1 j=i ^ ) "][ I ) 3 (pM,+b.) -^l 3 -^ j=l =• ^ (pM^+b 6 j: and where Y is a vector of random observations, f(Y |9) lognormal density with vector parameter 9= /^ ( ,0" ) , is the M^ and M^ are the first two moments of such density, N = population ^ J size, n = saunple size and b. = ^ Y. . Our main goal in studying this expansion is to obtain approximate maximum likelihood estimates (MLE) for the parameters of the underlying lognormal density, K and 2 <J , and for the finite population size N. Namely, defining the like- lihood function for 1( A. lues O-'^.nI ( k, (7 Y) K , CT^ and N given a data vector Y as we wish to find a triple , ( K,, (?lf ,Nq) of va- that maximize 1. ,N) ML estimators may be analytically obtained in the limit, as N -»o<3 ; hence a question of interest is how large should N be to actually obtain in practice a MLE of all three parameters J^ , Xr^ and N. It is also interesting to get an idea of how stable these estimates turn out to be as a function of the sample size. The approach we took to numerically analyze the be- havior of the likelihood function for particular samples was to construct iso - contour graphs of it. Doing so in two di- mensions with one parameter fixed allowed us to visually de- 1-4 tect interesting properties of the function. What we did was the following! Taking the population size N as fixed and regarding \^ and <r as arguments of the likelihood function, we generated sets of points in the ( A,'^^) plane satisfying 1 (/^cr\ N I = k, Y) with k fixed, (Such sets of points are called iso Plotting sets of such iso - - contours). contours for different values of the population size and different values of the sample size, we gained some insight into properties of the likelihood function. In what follows we will describe these properties , along with the estimates we obtained for the parameters mentioned above. In a different context, certain methodological de- tails of the design of sin iso - contour generating routine turn out to be interesting as well. While it is easy to find a set of points satisfying an iso - contour equation (over given intervals for the function's arguments, and provided we have tabulated function values for points belonging to those intervals), what constitutes a more difficult problem is to order them in such a majiner that a plotting device can go from one point to the next actually drawing the iso - contour curve. Thus, we will also describe the method we used in writing the routine which generates ordered sets of points belonging to a given contour. Some details are particularly relevant when one is interested in the function's extreme 1-5 points; these will he emphasized in the corresponding section. Program details, including actual program listings, are inclu ded in Appendix A, As for the routine implementation, we have it wor - king in the TROLL system environment, taking advantage of cer tain plotting facilities already available in this system. A couple of macros which make the routine invocation easier from TROLL are included in Appendix B, along with their operating procedures. Finally, some data referring to program requirements (memory and execution times) are outlined in Appendix C, 2-1 2.- Iso - co ntour p:eneratinf^ routine. Outline of the method employed As stated in the previous section, the main diffi- culty lies on the proper ordering of the set of points belonging to a given iso - contour. The procedure we followed, ins pired by that described in (2), orders the sets of points as it generates them and solves other problems that sometimes arise, such as having two or more disjoint iso - contour branches in the intervals of interest for the function's arguments. Although some ])ublished material was available des- cribing programs also motivated by the method introduced in (2) ref. (3), (4) , they were badly documented and not par- ticularly well suited to interface with TROLL. Further, some interesting problems arise when generating an iso - contour near the function's extreme points, which were precisely the ones we v/ere more interested in. Our final procedure differs slightly from that in (2) regarding to these problems, amd so we thought it was worthwhile to briefly describe it here. A general outline of the method will be presented first, so that those problems may be more easily understood. What the routine accepts as input data is a table of function values in the points of a rectangular grid defined by a set of rectangular intervals of the function's ai^- guments, with increments that may vary along the intervals. In such a grid, two units turn out to be of importance when 2-; the aim is to generate iso - contours; namely the grid edges and the grid cells. Grid edges are used as units during the first step of the procedure, in which each one is checked to see whether or not it is crossed by the iso - contour being built. A way to conduct such a check is to test the condition (f^ - k) . (f2 - k) (a) ;^ for every edge in the grid, where f. and f^ are the function's values at the edge extreme points and k is the level of the desired iso - contour. Successful tests are recorded during this first step, so that when it is finished (having tested all the grid edges) crossed by the iso , - we are left with a set of grid edges contour under construction. Two properties of this procedure must be emphasized at this point. First, test (a) will only detect at most one crossing point at any edge ze is too big, ( so that when the edges' si- situations such as the one depicted in Fig. 2.1 will not be properly recorded), and points of tangency Fig. 2.1 between grid edges and iso - contour lines will not be recor dcd at all. Second, the procedure will go on in its second 2-3 step to locate the points of intersection between edges amd contour lines, so thkt the points contained in the resulting iso - contour set will all lie on grid edges. The second step of the procedure takes grid cells as working units, sind relies on the fact that when the grid size is properly chosen, either none or two edges of a grid cell will be crossed by an iso - contour line (in general, if tangency points are not recorded, an even number of edges will be crossed in any grid cell; when the edges size is too big, again, a cell may be crossed in its four edges, this is a situation likely to come out near the function's extreme points and is one of the problems that will be analyzed below) . What this second step does is to detect an iso - con- tour starting point (by locating any crossed edge resulting from step 1, and giving preference to boundary edges to pro- perly locate possible incomplete iso - contour lines in the region defined by the grid, as these have a well defined starting point at the boundary), and follow the contour line through adjacent cells to the one containing the starting point. This operation of following up the line is an itera- tive one which is done as followsi 1.- Having located the edge containing the starting point, set it up as "current edge". 2,- Delete any record regarding the "current edge" as being crossed to avoid coming back to it thus building up endless loops, 3.- Locate an iso - contour point in the "current edge" 2-k by means of some interpolation procedure between edge extreme points; save it as next contour point. 4.- If a "current cell" exists, go to point 5; otherwise decide on one grid cell to which the "current edge" belongs (in general, there will a choice among two, unless that edge is at the boundary; either one will do) ; call it the "current cell". 5.- Of the four cells adjacent to the "current cell", pick up the one having the "current edge" in common with it (notice that this cell will have either none or one crossed edge, as crossing information about the common edge was pre- viously deleted); call it the new "current cell", 6.- Check the edges in the "current cell" for crossing information; if a crossed edge is detected, call it the new "current and go to point 2. When no crossed edge is de- edp;e" tected, the iso go to point 1 - contour is complete. Record this fact and to look for other possible iso - contour bran- ches. Such an iterative process will be better understood by following the sequence of sketches in Fig. shows the actual iso - contour being built eind 2.2, where (I) successive ones refer to procedure steps (a x stsinds for a crossed edge, a dot for an iso - contour point in the resulting set of points; the shaded cell is the "current cell", the darkened edge the "current edge"). At this point, we are in a better position to dis- cuss the kind of problems that are likely to arise in the neifh 2-5 Result of step I M 1 K I V7a y± (1) (2,3.^) (5.6) (2,3.^) -T/ T/ 'ZIM- (ZM^ (2,3,4) (5,6) 7/ (2,3,4) is.e) Fig. 2.2 2-6 borhood of function's extreme points. We will discuss three of them. As has been emphasized repeatedly, grid cell size is critical; near extreme points this is even more true. It may happen that, the grid size being too large, an small iso - contour near a function extreme point will be roughly contained in one grid cell, as depicted in Fig. 2.3. Fig. 2.3 Such a situation violates the assumption that either none or at most two edges were crossed on any given cell. There is no way of deciding in which way the four points in the cell should be joined to generate the iso - contour curve. The- re are three possible ways of joining them as shown in Figure 2.4. The way that eventually will be used by the procedure Fig. 2.4 described above depends on a variety of factors, such as on whether it picks one of the cell four crossed edges as star- 2-7 ting edge or not and the implicit sequence on which cell edges are checked for crossing information upon having it as current cell. No reasonable way oi solving this problem without changing the cell size (so that the four points will no longer belong to the same cell) was found, unless assumptions are made about topological properties of the function being analyzed. tions it is not safe to make any of these assump- In our case, - at least in principle. In addition, given that one of the goals of our study is to determine extreme points, a finer grid is needed in any case to obtain precise estimates. Hence we decided to apply a finer grid whenever this problem appea- this is another situation which points out red. Curiously, the weaknes of software procedures in dealing with pattern re- cognition; most of the early approaches to such problem were very similar ;i.e., superimposing a grid to the object under inspection and being unable to infer deatails from the general pattern. In our case, it is obvious that a human being, with the help of nearby iso - contours would have no problem in joining the four points in that cell in the correct way. The procedure doesn't generate such information, as it cons- tructs one iso - contour at a time, but there is no apparent (iii way to make "Mailable to the routine to solve the problem unless very inefficient prQoedures, such as slope matching are used A second problem, particularly relevant when the function under study is very flat near the extreme points (and this was our case, as it will be seen later), is to get 2-8 a set of adjacent grid points all with the same function value, in turn equal to the level of the iso - contour being construc- ted. The situation is illustrated in Figure 2,5. Assume the values besides grid points are the function values at them, and that we are building the iso - contour of level 5. What 4 2-9 as crossed (notice that when those points are at a relative minimum the disturbance has to "be in the opposite direction) . 3-1 3.- Asympt otic expansion behavior and maximum likelihood esti- mation. We had at our disposal two sets of sample data to study the behavior of the likelihood function generated by the first is a set of 2k North Sea pools and the se- themi cond is a set of 5^ pools from a play in the Western Canadian Sedimentary Basin. Before going any further, it is important to say that the chronological order in reservoir discoveries is of central importance, as the sampling process is assumed to be without replacement and proportional to -remaining- size. Some of the results obtained using the expression of the likeklihood function on those samples are summarized in tables 1 and 2. In them, the values of ^ and cr which maximized the likelihood function for different values of N and sample size n are shown (When the sample size is less than it has to be interpreted that the actual value stated above, the sequence of first sample values was used as data, thus preserving chronological order) The estimates for , were computed analytically, that is, cr^= A — ^ " i=i log g 1 , log g = -_ - ^ log g)^ - , / ^1- and Y. stands for the J (log Y, where log ^ Y. J j observation. N = ^^^ 3-2 TABLE 1 NORTH SEA DATA n 3-3 TABLE 2 WESTERN CANADIAN SEDIMENTARY BASIN DATA n 3-^ The column labeled "Figure #" indicates the iso - contour plot corresponding to each row. In these plots, the axis labeled cr "SIGMA" actually corresponds to values. We will center the discussion in the values shown in Table 1, as we have a wider range for them and the operating characteristics of the asymptotic expansion for the likelihood function which we detected seem to apply to the values on Table 2 as well. The main feature to be pointed out is the degree of instability which shows up for U and cr estimates as stays N constant and the sample size is chajiged. More concretely, as the sample size n increases, ML estimates (keeping N fixed) for U and t'' vary systematically! the estimate f or creases while that for cr in- JU. goes dawn. Furthermore, as n takes values below a certain level, such changes in yU and cr*" estimates become more apparent, taking values very different from the ones obtained for lar- ger values of n. This is the case for n = 12 in Table 1 (even for n = 15 with those data such a behavior begins to be very apparent) and for n = 30, 20 in Table 2. There are, as we can see, two two main reasons for such instability. The first is probably a consequence of sample data variability, which is relatively more important when the sample size is small. The characteristics of the samples we had -perhaps due to the fact that oil producin;-: areas are so recc'-nized when important discoveries take place, no that some early observations tend to be large- was such that 3-5 when used in the likelihood function produced a bimodal behavior v/hich was hard to detect as the second relative maximum builds up in a region where the A and (T^ values are unreaso- nable as estimates of the underlying density. Moroever, the second relative maximum tended to be more important as N increased for fixed n. As may be seen in the plots corresponding to N = 5OOO, 20000, 100000 when n = 24 for the first sample (Figures 11, 12, l4, 15, 16, 17), it rea- ches a point where becomes more important than the first one. vVhen this for A and happens, those values out of the reasonable ranges <T mentioned above begin to appear. For very small 30 in Table 2), sair!X)les (e.g., 12 in Table 1, 20 or it seems that the second relative maximum has taken over completely, and it is" the only one obtained in tho- se cases. Before discussing the other reason for instability, m.ore intrinsic to the nature of the problem and less related to data variability, it is perhaps worthwhile to make a motho- dological point for using the iso - contour routine or a si- milar tool in numerical analyses like the one described here. We would recomend a wide range on the function arguments to take the first pictures, forgetting aboufreasonable" values around which the function is expected to behave in a certain v/ay (e.g., to have a maximum). Having an overall idea of func- tion behavior we can then concentrate on certain areas. If this step is omnitted, the first results tend to bias the ana- lysis to pursue a certain region without paying any attention to others which may contribute heavily to explain peculiar be- 3-6 vior. In our environment, doing so implied a loss of detail, as the plots we generated were fixed in size, but even in this case it proved to be in the right direction. The second cause of estimate instability was due to the extreme flatness of the function near its maximum(s). As it may be seen in the enclosed plots, this circumstance did show up rather strongly. Thus, small variations in the functional form due for example to small changes in sample data are likely to produce relatively important changes in the lo- cation of the function's extreme point(s). The changes observed in the location of maximums were not, however, completely arbitrary. What happened was that the iso - contours we generated were roughly elliptic, and that the main axes of such ellipses tended to conserve their orientation in the A - o^^ plane. More concretely, the main axis tended to conserve its location, so that different estimates tended to lie in the line define by it. This may be seen as a common characteristic of all the plots we include. As a function of N with n fixed, the iso - contour plots show that the function gets tighter along the small ellipses' axis, but being still very flat along the other one. This suggested that the underlying colinearity between U- and rr^ estimates in the limit as N-*<» (see Jx.^ and cT^ equations above) could be somewhat preserved for finite values of N. Visual inspection of the plots pointed out a line equation close to h = 3.775 - 0.8 cr^ for the first sample as main ellipses' axis. In the limit, for 3-7 n = 2k, the equation Is ^oo= 3.78274 - crj , not very far off the one visually fitted. This would explain the overall trend of JU and (T^ estimates as the sample size n changes which we described at the begining of this section j it may help to foresee their behavior for different sample sizes. We were also interested in obtaining an estimate for N, the finite population size. Our results in this regard are not very conclusive. As shown in Table column labelled 1, consulting the "Likelihood values", it appeared as if for N = 303 we obtained an absolute maximum. However, as we had other results for increasing values of N, the function value increased above the quantity -128.12 corresponding to N = 303, and, what is worse, the overall maximum (up to -116,511 for N = 100,000 in Figure I6) is attained at a point with unrea- sonable values for JU and cr^ . Thus, at least for samples as small as the ones we had, ML estimators for N appeared to be quite instable, and other estimation methods should perhaps be tried to ebtain a value for the population size. It has to be seen, however, how the asymptotic expansion works with regard to N for samples with a larger n. It may well be the case that our sample sizes were too close to values for which the second function's relative maximum begins to develop, thus jeopardizing the function usefulness in the relevant range for ^- and cr^ . To summarize, the two reasons for estimates' ins- tability discussed above have pointed out how sample size 3-8 influences the estimates we obtain with the analyzed likelihood function expansion. Its pathological behavior for small samples seems to suggest that having more numerous samples would help to obtain better estimates, not only because they provide more information, but also because the likelihood function begins to behave better when n increases. HiLLMOy T.HL flP'iT l COMlOilk 'trtLUE'i hREv THE RE'iT hS IH FILE LEU2(dO y 4U siGrw Fifiure 1. I THfc: FIRST Zi COflTOUR 'JAUJtS lc:^.B--1^3 5.C--129 -HS0B3OO' f<- IcJci J fiPE ' THt PEST f*^ Itl f ILt L ( "I I u <o . '. fl u SIGHA l''ipur<^ 2, I HSO&^e.i FIRST 3 COHTOUP sirLUES RREC THE RE5T RS IM FILE LEUEL305> ":S 12 B=-128 2 C— 128 3 H-=-l . . 3 . . y© 2 00 1 ?0 I 00 1 1.50 l.?5 2.00 2.25 2 50 2.75 SI cm. Fif^ure 3. .-NS0B4e>0^ THiT FIRST u ^ 3 COflTOUP UPtLUCG W^CfTME PECT H'J ID T I I.C LC 'LI Uh>. M'^iiD'r.iJM. FIRST 'i COflTuUP '.'hLUES hREv THE PEST hS IN FILE MI2450O:> H-- '8 269 B^^ 123.5. C^- 29 1 r . . •1 . iiie I 7 00 1 00 GO j"i 00 Fipiure 5. /-MSOB600 % no - THE FIRST 3 COf<TOUP '.lAUJFS APt THF kE^T hS ' Ifl FILE IF''KI..-.>n t'-.0t:r5i;i HIRST 3 LOtrrOUR UhLUES HRE<.THE rest Hi U\ FILE LE"2:475HJV B=-12y 75 C=-K'?' H--'\:e. 463.. L 4 Mt't . • Fir.ure ?, I, .:'. -I (1 FIRST THt 'H',()U'J'*-> U- t \---l(i-: "r 3 < . COf<TOlJP - 1 >>ftLUF<=> ^Rt ' THF. f-t r> T M-i> Id K r I f. ' I f '( clO .K f'l X .1 . I I . s I cnm Fir' lire 8. » H-^.j'HiM FIRST 3 CONTOMP fv- lJ/.&9-t B-- 128 5. 4 H'.-1 z ijy) 1 00 1 — '.'hLUES hRE' THE REST AS IN FILE LE'iSOOO)'. 12:^ — 00^ 2.5 SIGMH Fip:ure 9. '/ *t H-;:r!Oj. Flr.'ST -1 I? 1 5 3 CCiNTCKJR UhLUES RPE-: THE REST -I e -b.e Finirt- 10 rtS IH FILE l.Ei '2ririi3 >: THE FIRST 3 CONTOUR UhLUES NS^.y^3ei H^-1.J7 4 "^^^l .B=- 123.0^-12:8. rtRE< THE REST AS IH FILE LEM5900 ^ •: 00 00 2 00 1 00 U U0 00 1 00 00 3.00 4.00 5 00 SIGMA Figure 11 -H'l.fonrt 'FIRST 3 CONTOUR l."HLiJES ARE< THE REST US IH FILE LE"5O0OV H--l.iS.257.B=-126,C— 127. I.L0IJD'4.0P1] ^1 0.0 -4 -R fi -12 n u . Fipuro 12, 'NS10O0W' THE FIRST 3 COflTOUP ^127 -;c^'L,.E--ia7 2.C--122 C i lJl.l '-J^^UJES ^»f^EMHL Ht'^T H'- It( F IlL L("l.H>i>oi i' .Tirirni THE FIKbT 3 CuHTiillP UhLUES hRF- THE FEST MS IH FILE LE2O0OO 2 MO »Z1 0L1 LI uO 1 Od Fipiir*.' I'l > FIP'VI 3 U.iMIOUR 'IhLUES ly 691 .PJ" -121 .C ^-l:.:':' t u !i,"t"'"iari H --) HPEaHE REST hS IH FILE LEcOOOfi 7 fi -4 ri •-! '.L%^ l»w •.]• 12 0*-*n tj .t-.«. -I — ..»._L_4—I l-l* 15 Id If.flH I'ip-ure 15. ^i:iri,::n.i»i FIRST 3 cotnoup "IhluE'5 are-: the rest hS ih file l''i£'ure 16, LEimmo> HlOriMo H-- -1 16. •FIRST ill 2 LUHTOUR '.'HLUES ARE'. THE REST AS IN FILE LElOfiOOe^ .B=^-11S.C^-12£. Fif^ure 1?. US JU^Oy FIRST X COHTOUP UrlUES rREC THE REST 827 B--103 y i:=-104 LL0M3.nfi H-=- 1 fi3 . rtS IN FILE LEU2O3O0 . [1 2.50 3 GO 3 50 SIGMA. l'if;'ure l8. Ol.E- <.-10/» 1 J.',--104 V 11:34 '.' I =^o 2 00 a 50 l'Ur<ti-f' 19. 3 00 3 Sw 4 00 HSJj£:Hri- FIRST 3 rntnOUP "HLUES ARE<;THE rest hS IM file LE'il2.2O0>^ H-- 'yj 7C?2;3.. B"-bW.C-- t"ti I 50 1 Ciri . y0 4 . QGi flcfOlS r<V.12?tiO 'FIRST 3 H=-,- .n 0863 B---bCi . I COHIOUR 5 . L =-61 '.'fnUJES . ftREt; THE REST RS IM FILE LE"12.300) DSaSOe- THE FIRST 3 COnTOUR 'v»ALLCS APEfTHE REST AS H--31'* 0^3.E--314 5.C--31G . 3 4 1 SO ir» FILE ttU- L-^i>.^n r.i':.?li:^nj Z 1 Otl 50 J nO THt: FJRST 3 COHTOUR OrtUJES HRE<: THE RE-^.T hS lU FILE NIT.21000) ti'... i'".ni.i 1 40 H 'r.l'J U JH THfi FIRST - LUNliJUP UhUJES HPE'THE PEST hS IH FILE MT"l^.yO) !j"..Jm.ih ^irsr \i rOflTOUP HhlIJES JhREXTHE pest hS IM file HI5220Q0 _ Kirure 25. — 040 lOrnj FIRST 3 ? rin 1 00 COHTOI.IR iirUJES rtRE<. THE REST 00 Firure 26, rtS IM FILE HI4OieO0V rj.itn>_iL'- 1 iin ij Giy 1 FipjT ""jO :-; cijuimlip <^hujes hre- the pest Hi m file hi40150O>^ 2 00 SIGMrt I'i.^ure 27. [I4H.MHLT i --:-1-? 1HE-. 442,. ! o0- 1 2m !1 t-Tl f-lPIT 3 CONHJi.IR 'inLUES APE' THE PEST hS B^-^44 o.rn-.244 3. M uy l'iifm-e 28. Itl FILE ni402000v [ .iiV-.Mn ! THt: Flh'Sr -'. CONTijUR UhLUES hPE'.THE rest hS in file MI4e3OG0) SO J-; iJM 2 T'O 4.00 4.50 t^ 00 "^^ SIGMh Fip"ure 29. '^-•yy [J-Mi!;:nj6 ^ = - ] :-.^ . FIRST 3 COHTQUR ?1^ .. B- 1 84 2 . . L ' 'HLUEb hPE( THE REST hS IH FILE MI3C)100ei> -- 184 5 . i'jrure 30. THM FIRST B=— 183.6. D=-.i_il^.MO H^-\--ri. 1 34:::.. 7 CONTuUR "ftLUES RREf r:^-18/^. THE REST Hi IN FILE MI 38 1500) 50 7'. n fiH :f uG Fifure 3^- n:-:u!aej^ M 'j -5 :; yfu THE FIRST 3 CuNlOUR UALUES ARE<: THE REST hS IH FILE HI20MILA)^ Li":n:srn3. f-JPbl H -- 1 .-•9 ,' '1 1 'i-ij 1 tiO n sfi w wO . '- 76 1 B-- 1 "^Li on . , fUHruUP nnLMEr. hPE. L ~ 1 '_^M ':• ^ HE REST hS IM FILE MI201500>^ APPEND IX A Iso-contour plotting routine desc riptlon_ and progrram 1 i s t i g^s. The iso-contour generating routine consists of a set of FORTRAN and 370 Assembler subroutines which form a package. CTOUR is the name of the main routine in this package, and its purpose may be generally described as follows Given a tabulated function of two independent variables f(x,y), it determines sets of points belonging to the ] o- cus defined by the equation f(x,y) = C, where C is a given conj? tant. (Subsequent calls to CTOUR with different values allow C to obtain a set of such loci). 1 . - Procedure CTOUR employs as main procedure the one described in (l). Roughly, it works from a table of function valuer; at points of a rectangular grid defined by two auxiliar input arrays (which permit the use of variable increments in y along their respective axes). Given a value for C x and in f(x,y)=C, CTOUR begins by marking all the mesh edges crossed by the locus defined by the above equation (an auxiliar bit memory is used to keep track of edges); then it computes the coordinates of the crossing points by linear interpolation between func - tion values ad adjacent grid points. Points belonging to the locus are returned an result, ordered in Huch a way that it is possible to actually draw the contour by (1) just joining thtMn Automatic Contour Map. G. Cottafava and G. Lo Roli, Comm. of the ACM, July, 19^9. A-2 as they are found in the result array. This result array may be logically divided in subtours, when the locus f(x,y) = C is such that it posseses disjoint branches in the domain de- fined by the grid, 2,- Input and output variables description. It is assumed that CTOUR will be called from a FORTRAN program. Its calling sequence is as follows CALL CTOUR A NR NC XS YS ALEVL lA PTS NDPTS NPTS ( , , , , , , , , , ) where: A is a bidimensional array containing the tabulated func- tion values. By convention, X values are constant along A's columns, while Y values are constant along A's rows. For convenience, A must be bordered by two extra rows and two extra columns which do not need to contain function values, but which must be included in the count to deter- mine A's dimension. as declared in the calling NR is the number of rows in A, program (including the extra first and last rows). NC is the number of columns in A as declared in the calling program, also including the 2 extra columns. XS is an unidimensional array with NC elements containing the X values corresponding to different columns of A. YS is another unidimensional array with dimension NK con- taining the Y values corresponding to different rows of A, (2) (2) In other words, A(I,J) = f [XS( J ) , YS( I )J . A-3 -ALEVL is the function value for which the contour points are to be determined. lA is an auxiliary memory taking the form of an unidimen- sional integer array. It must contain at least ((NR-1)*NC+(NC-1)*NR)/32| elements, and it must be declared accordingly in the calling program. PTS is a bidimensional array where the locus' points are to be returned. It is of the form PTS(NDPTS, 2) , where PTS(.,1) will contain X coordinates and PTS(.,2) Y coordinates for the resulting locus' points. -NDPTS is the maximum number of points that may be allocated in PTS (i.e., lling program) its first dimension as declared in the ca. If CTOUH reaches this maximum during the process of filling PTS, it calls another subroutine (EXTEND) which is supposed to save the contenlB of PTS when enough space to do so is available, cancelling the whole process otherwise. An actual program for EXTEND is not included below because it is likely to vary in diffe- rent environments, - NPTS is a result integer variable indicating how many points are returned in PTS. 3.- Example. In what follows we describe how to set up the input variables for a call to CTOUR in a concrete case, along with the output p^enerated by it. Imagine that we have a function f(x,y) tabulated in the interval [l 6x^-3, 2^y^5] , by increments of 0.5 in both A-4 X and y, and that we want to call CTOUR to obtain the set(s) of points belonging to the locus of level 4.5, that is, be - longing to the curve defined by f(x,y) = 4.5. If that is the case, the input data should be organi7,ed as depicted in Fig. A.l, and the grid being used would be the one shown in Fig. A. 2. Assume further that the iso-contaar f(x,y) the two branches drawn in Fig. A. 2. Then, =4.5 has the result variables returned by CTOUR upon call with the Fig, A.l variables would be of the form depicted in Fig. A. 3. Notice that the first point of a contour branch is repeated as its last one to actually close it, unless the branch is incomplete with starting and ending points at the grid boundaries. Different branches are separated by delimiters labelled NA in both the x and y coordinates. 4.- Brief process description, with references to actual programs, All subroutines are written in FORTRAN, with the ex- ception of MARK, ERASE and SEE which manipulate bits in the auxiliary memory lA and are written in 370 Assembler for improved efficiency. b'ip-. A. 4 shows a high level flowchart for CTOUH, in- dicating calls to other subroutines in the package. It is quite straight forward, although some steps need further explana- tion. Following are succint discussions of such steps and the involved subroutines. - "Clear auxiliary memory" just sets all the integer ele- ments in lA to zero. lA is used as a bit array, each bit corresponding to one NC=7 ys 2.5 3.5 ^.5 xs ^ A-6 PTS 1. A-7 f \^ CTOUR entry ± \ Update PTS J __ ;all NEXT. let next ed NPTS=0 'e jy crossed" contour Clear auxiliary memopoint & NAs fEXTEND may be needed) Mark cells' edges crossed by con tour Call EDGE, Id^ntiry in which edge Call STPT. Locate an starting point Call IlilTER Vetermine. yes its coordinates. Compute & save its coordinates Call ERASE Assure we won't find it again. NPTS=NPTS+1 yes no Call EXTENE Fig. A. 4.- CTOUR flowchart. . A-8 points. The correspondence between lA bits and grid edges is established as follows I Edges are numbered as depicted in Fig. A. for the case of a 4 x 7 grid (vertical edges by rows first, then horizontal edges by rows). Having done this, given an edge number there is a corresponding bit in lA. For other uses, however, 3^567 — 23—|— 24—|— 25—[—26—|— 27— 12 I [—22— |— 28-[^29 -j— 30—|— 31—|— 32-|-33-( 8 10 9 11 12 13 14 |— 34-|— 35-|— 36-[-37-[-38-|— 39-| 16 15 L. 40- 1.7 18 20 19 .,-L 42—1-43—^-44 21 -^45 J Fig. A. 5.- Edge numbers in a 4 x 7 grid. an edge is more conveniently identified as shown in Fig. A.6t The vertical edge joining the grid points (I, J) and (I-H,J) is speci- (I.J) (I,J+1) (I+1,J) Fig. A. 6.- A more convenient edge specification. fied by means of the 3-tuple (I,J,l), and the horizontal one joining (I.J) to (I,J+1) by (I, J, 2). The subroutine INDIA translates such specifications to edge numbers to manipulate the bit memory. - The subroutine STPT scajis the bit indicators in lA looking for I's by mea^s of calls to the subroutine SEE, which accepts a bit number and returns a variable =S ) if the bit is < > . A-9 Boundary edpces are checked first, to locate incomplete branches effectively. STPT returns an integer variable K equal to the number of a bit in lA currently set to 1 . If no such a bit is found, K is returned set to zero. - Calling the subroutine EDGE with a bit number K returns an edge specification in the form already seen in Fig. A. 6, by means of a 3-tuple (I, J, KIN), (i.e., EDGE performs a transla- tion in edge specification converse to that one done by INDIA). - INTER interpolates linearly in the edge specified by (I, J, KIN) to end up with a point (XXX, YYY) such that f(XXX,YYY) = ALEVL (with the error proper of a linear interpolation; if such a method is considered ineffective for the func- tion at hand, it is easy to write an alternative INTER subroutine to perform a finer interpolation, although this circums- tance is unlikely to arise as other considerations -see section 2- force the grid cells to be of a size where interpolating li- nearly is usually enough.) - ERASE accepts a bit number K in lA and sets it to zero. - NEXT accepts an edge specified as (I, J, KIN) and looks at the adjacent cell searching for another edge crossed by the iso-contour under construction. If such an edge is not found, the original cell itself is checked for a crossed edge (because on the boundary it may happen that the adjacent cell does not have another crossed edge). When this search also fails, the contour branch being treated is complete. Cells are identified by means of their north ner, and their edges by means of a variable set to h according to Fig. west cor- 1 , 2, 3 A. 7. Notice that the k edges heve to be or A-10 identified here in order to effectively locate an adjacent cell, (I.J) Fig, A.?,- Cell and edge identification for NEXT, Given a cell as (I, J) and a value KIN(=1, 2, 3, k) indicating which edge was crossed in that cell, NEXT identifies the adjacent cell as indicated in Fig. A, 8 (where x indicates the cro(I,J) KIN = 1 (I KIN = 2 ;ot 10 ( A-11 LKASh SI ;;c f_ C ** #« ^: CHhCK ?..0 DATtr CHFCK(IA,I,J,KIN,NK,NC,K) IKK OUT IMfc 7b079 04/01/;'H C HE 000 10 j;: CHF00020 y,: KS IF THt CFLL (I, J) HAS A CKDSSING tOGE OTHER THAN KIN, WHICH CHE00()30 WAS ALKFADY FRASFI). IF SO, RETURNS IT AS (I, J, KIN) AMD K, IF NOT CHE00040 IT K FTDKMS K=0. CHEOOObO DIMI- MSION IA( 1 CHE00060 CHF00070 CHEOOOHO ) KMFX T=KIN ,3 CHEOOO'^O T=KNFXT+1 IF(K NEXT--^) 20,20,10 10 KIMFX T=KNEXT-A ?() K = M 1)1 A , J,KNFXT ,NR ,NC CALL SEE( IA,K,N()YhS G(l T (1( 30,40) ,NI)YES CHFOOIOO CHEOOl 10 3 ni) L= I KNiFX I ( I ) ^0 CIIMT INIJE K=0 keil) KN ^+0 K I M = KNEXT RFTII KN FM I") ) CHFOOl 20 CHE 00 130 CHFOOl 40 CHFOOl SO CHEOOl 60 CHE 00 170 CHEOOl HO CHE00140 CHE002 00 CH|-0n210 ,4^1 A-12 L h A S F ? DATh CTDOR . SilHkdllT iMh CI illiRI A ,(\IK ,imC,X,S,YS,ALFVL , I 7bl?0 1 A ,(^TS,N|)M I SflMHTS '^/?3/\H CI ) C :*:;: *V ;:;-:;: RKTHKIMS I. AL FVL KVH L A^ f; I I PIS IM MFMT S 1) K I.) t" R1 S I? T S 1.) PDIMTS ftFLDNGIIM. TO CDMHUIKS llf- 11 1 CTi . . =:^- VAUIFS IN A (,K O. - A J IS iHb VALDF F(XX,YY) WHFKF XX=XS(J) L YY=YS(I).A MUST HAVF KDWS MC CHLDMMS, AND |HF«F MOST HF 2 |\|R X K A KdwS 2 FXTKA CIILI)MNS( FI kST LAST), FDk WHICH IN IT IS ivi(Jl IMECFSSARY TO SP^-C F Y F( INC T VALUFS. MK.-SFF A. -* NC A.-FI)IMC =-;< -* ^:=- r IIIN [ ( I , ) t. =:=- f- i. =;--- . -SFF A XS.-SFF YS ^:= =:= . I i\ 1 I =;=-;= 1 . A. -SFF A , UN VALNF FflR WHICH A CdNTlHIR IS DFSIRFD. A.-AI)X n. lARY MFmhry.IIS ni'^lFNSIlIN IN THt CALLIN(, PKII(;kAM SHOUIJi HF NC-l '^'NK+INK-l jl'NC )/^2+l P IS.-HIIIN S KFIJ)N(,IN(, Til THF ONFRA(FI) CDNlllDR. Miipi s.-i nii-ihNsniN uf pts in ihf cai.lumc; PRiicRAh, R s ALFVL .-FIINC -=:= *=:= I I I -* ( =;=>;= ( ) I =;:-= I I (IIS SFCIINI) '^'^ NP =;^>;- FX1 -.- I iMDP >;=';= I I S I IS 2 ) FLFMFNIS RFTHRWhli IIF PRIIVII1F III CI c n CTi c C(i CI CI CT I C7 cri C C cri CI c F I I (. , IN PIS. SPACr i-nW PIS WHFN SLIMS HAVF hFFN FXHAHSIFD, S.-lMllMHFR NF FN|).-i<f.ni) A( INMIAI hoilj VAI.FNt.F I ,NC ,XS( ) imC ) , YS( N'R ) , I A ( 1) » P I S ( NI )P I S , 2 ) NA//F(-()FFFFI-/ li0"|/\ i\lp \-i\< ( NA , I (.1 IHF Cl C II C Ml ht-MSKlN 1 CI (. C ?N(\) C ^ = C I I I I I C CI Cl I =::;.; K = l I + ( A( I ) MAi^K FlRSl DH M |J ,-1 ?? = 1 1 = 1 ( h ( ( F ( /\ I- ( ) *i\iC ) /A? C |\| K- I T C C Cl c r I CFLLS' FIM7FS CRiiSSFO ky CHRRFNI CH'MIIIDR llK LFVHI. ALFVL. AND LASl RiiwS L CllLU^'i^'S A R h NOT HAWKFD(THFY AI.LHW Id FJi^ISH =r.ic, - 1 , , ,) '•(I ,.1 IMIi^ S CRI IS S I hlO THI- (^R I D HI II IND A-< F S I ) . (.1 c (, 1 ,l--2 I I r 1 =/ A( ( =;=lMk+(Ni^-l ,K I .l-NCl"!] I ) I'lF'iMRY. =0 10 I I- I I I /() I Dl I i\iC-l SIIKCIIN i\ic,M Dl ( 10 III! 10 AI)XILIA.^Y CLP/\R , iMKl^i ,DCI« ) (. I (. I I 2(i., AOt'+D J )-ALI-\/L ) )-ALI-VL + )-ALI-VL ) 1 1 1 -( A( -Iw ) I , ,1+1 )-/-I.FVL , 22 , -(() 3 0, A I), 3 ) ) ^0, 2 1 ,40 c c I I I \0 r, Ml w , ' I I )?\ |;*** V c, i IOC lie jf?*« (II c f HfcCi f?n ^/(> fOp- A-13 1 f^:.;:-=;: Himi AL ?()\|1 eiK^F 4/ ;^ H / 1 H CKII,SSf-|). C ll0i)4M() I C C CI C C C CI c C1 C I •-10 K=IM|)IA( J,;^,MK,i\)0 , 1 ) CALL MARK h 40 -MKMl I 1 ( f ( ) A,K ) '5) It-( ( hO, /(), n) I t^ A I H "^ r =;- =;= * ( ( I A( ( )-ALhVL)=M A( + l, J )-ALFVI.) )-ALl-VL 6U,h^,60 +1 J )-ALhVL (SO, 7 0, 6 A( 1 , , vJ J I , I 6U,'^],70 ) ) ) -;= r.=;:*.-;=* V(-K"IICAL CRdSSFD. hDGI- C «--=:= nf)Oh'-^() I lUMi')A(' ] IIOf)'^SO I iiO'isyo K = iMDl A( I MARK CAIJ. 70 Cum I , J, ( I ,IMK ,ImC 1 noosHo MO CT(U;060n CTf lOOhlo A,K ) ) INIie. 1 lOOh^O I (10(1 6 ( 60 () 1 ll(W)hXn I ^'J IO0S(u I llfiKh I CI MOC'lS^O C IIOil6-(0 C iifto^Ao I r.:;=**.;= r* (^KU-CT CUMHMIK SIARTUMf, PlilMT. A I =:= =;= --^ (. 7'^ AIJ, r. S fP ) no. IF(K) 1 ( A,MR Ill), ,K ,i\)C C ) HO START AM RDIiMT Il\)(, i-jAS I- llllMO- 1 J Oh'MT 1 1- Y WHICH IM fcOt,^ IS I c^.^=;=** t-'.O C-* I (.1 II0() /()() CAIJ. I-I)GH(K ,I\|R,I\IC, I , J ,K f M) |)t- r. .;:;;:- ^h f^-K|^/lJ|M^- AHL H SAVh A|\)|) CLilSh HI THH C HDR O A WHt'M bNIH-D, I II C 110(1 /111 c inoii /?o lOO I -iO C 1 =;= ^;= r. ;;:=;:*.;: ;;: IIO06Mfi (|006W() I C lOOh ^O I I C r,*=;:.;=:,: I I (. lOM^hO lOdhhO I I i\J I h S THh l)F STARIJMI, H-illM I (. C CALL Il\ri [KS1 I- I- ( I ,.),K Ii\i,XS, YS,NR ,NC A,ALFVL, XXX ,YYY , ) XXX ST Y = YYY II H6 k I (-.1 LR I X = I noo /Ao I I I (, I (. I C I II)f-'l||FY (,RIJSS|I\I(, iMI)i\)| IM |-l)(,(- t^Y IN I l-.^Ml 11. A I llllvl. I I h[] / 70 I lOll /HO I lOl) /Wli (. I (IO(iHOO ( I I C CALL I IM 1 LR ( I , J , K I M , XS , Y S , I\IR , MC , /\ , AL h VL , 'C X X , Y Y Y ) ("•)() Kill I I (. io(i IKMl C lOOH 10 O M^ IIOOM -((I II I I C IIOOH^O C iiinoHho I FtiRi.FT CALL FRASI-( IIPIlAT F C =;= IHIS CRdSSlMG PMI'Ml. AHIIIII Pilliv I I A, K C C C ) SI-1 S ( s ) . (. =i' =;= >:< i\l I wo wH H I S= F ( i-l)P I CALL FX wk'! s = l R R I I S S ( ( IM R I MR! I S+ I S-NR I C C l-i\iO I ( S R H7 ) I S , ,^-'0 iMOM I ,40 S ) (. = X X X C (. 1 ) I I I ,/ )=YyY I I I , I I (, S I I (. S I I I I I I I I I I I I lOOhM) KHiH /I) lOOMHO lOi IMMI I lOMHOd lOiiw I (1 i0(-w/O KM -^O I'-J KKIO'^.d lonwso KMrvcid . !l!l? A-14 H/ASH i-l :;==:^ P.O CTIIDK Kik MhXI IJKK CALL M f_ :;:.-;: :;:;;: ) | I r,v«:;=:;= 100 I 1 1- IF X 7 /i , iM I 0(J, lot), ] ) ( iMilT, THKMIimA ( F( 101 I F ( PTS( MPl S, PTS( NPl S, o? I F ( M I F ( 1 lO:^ lf)4 1 S ( CKIISS Ii\i(, K I hXISi? II S K( K h- IM PTS PI S( MP] 1 1 , ;^ , i\ii: , I , J SO, H , 1 K 1 ) N , K F NT I I ) H Y 11 A IM \JU\K IF I ) I F SIIHIHDK A L ) ) ) ) ) -YS ( /^ ) 3 1 i'MRMl ) ) , 1 w , 1 H lOA, 104,104 i\iPTS = IF 104 ,106, 106 FXTtWLM PTS,imI)pTS 106 CALL i\' t-' ) ) T S= 1 106 PTSI MP S, 1 =F IKSTX PTS( ivpTS,2 )=F1WS1 Y 104 IMPI S = iMPTS+l 107 ,1UH, IF rioPTS-MPTS o7 CALL FXlFiMlX p s ,i\iOPTS ) I ( ) 1 oK '~ H P I . S= ( P TS (,i) (•; 1 S =;= Ivp IM OH 1 MP ( 1 ) I i\i 1 "I S , 1 rS,2 ) =/ IM /^ )=/iv)A 76. =; TFl-iM I l\IA I F. 7'Di20 MOINI, 101,10^,101 )-XS( ^ 10/>,10M,1U? )-XS( MCMl ) = CiinTINIIF H4 S,^ )-YS( NPtS+l WDPTS-MPTS D/iJ^^ KtrlHKM III CALLI'Ml. PKIICKAM. ANY riTHFK FXISIS, A-15 :Lf:ASh *- C Q* if. ?.i) bUGE SUKKGDTINE EDGE ( K TKAMSLATES K-> I, J, ,i\)R if if KK = K-( ( IF(KK) 10 K I I = J= NK-1 ( ) K-( ( ) /|\iC I-l ) + I = J = )=;mMC ) KK-1 )/(NC-l +l KK-( I-l )*{KiC-l ( ( KIN = ? RETURN END ) ( I ,J,KIN) EOGOOOm El)(70()0?() E0(,000H0 El)(,()0060 l RETURN ?0 KIN , 10/31/07 EO(,no()bo 1U,1U,?0 K-1 ;nC 7b084 En(,00f)4() )=;=|\IC M= ( UATH ) ) ) EOGOooyo EDGOOOHO EOGOOO^O EOGOOIOO EOGOOl 10 EDGOOl/^O Fn{;ooiHo EI)(,00140 E0(,001 40 t!*< A-16 I.t-ASF ?.() INIHA DATh = 7^083 11/3^/1 (S n ! 10 y I) p x x K 10 I \) p y V A-iy [-ASF INI hk ?.() SIIKKdDTiNK CI k I I MDlNl NTIUJK I) INTI-K( DAT'^ Ift/nO/A? I,J,KIivl,XS.YS,NR,NC,A,ALFVL»XXX,YYY) (;bNEKATh(),V A IS J, KIN). INTOOOIO IMT00O?n LIMHAK NT bkPOL AT I(li\M Y NG IN THI- MT 00030 HE kf^SMLT IS (XXX»YYY). iNl 00040 IM OOOSO INT00060 IMl 00070 INTOOOHO IMT OOOMO IM 100100 I I DbHINhO HY (I, Ei)Oe 75079 = 1 I I I II 1 MENS ON XS(MC I = ) , ) , A(Nk,NC 1 ni( 40,30, 10,?0 J=JJ+1 (I 10 YS (Nk ) ,K IN TO 40 1=11+1 YY=YS( ELT = XS( JJ+I )-XS( JJ IMl 001 10 I) ?() ^0 I 1 INTOOl ?0 IMT ) ( I I I 1 ) /DELI I ) FTDkN -^0 40 IMTOOl SO IMl 001 ISO MI 001 /O 1 [IM XX=XS( JJ ELT=YS( I1 + = JJ )-A( 00130 IIVJTOOl ) All , JJ + 1 )-A( ,JJ) XX=( ALEVI.-A( , JJ) )/k XX=XXX + XS( JJ = ) I 001 HO YY=(ALEVI.-A(n,JJ))/P Ml 00 I MO M OO/'OO M (uvi n IN OO/'/^O YY=YYY + YS( ETDkN I 1 ) ( N|) A( I I+l , 1)-YS( I I ) [I 1 I ) ,JJ) l/OELT I 1 I I I INI OO/'-JO 1 MTOO>'40 MVOO/'SA mf- m INIltX HUME A-18 pa(;f STATHMEMt SliDMCh- ASM niO'D ?1.1A STAKl FIMTKY FRASI-^Sbe STM RALK 1^, 1?, i;'(l 3) IISIiMf; =;=,HA,SF F KASF,0 K 1 F (M q I Foil 10 F 01 11 U ? Foil 3 F F (.) g 1 4 1 R(JMF,=F«1» I. LR SLL MASK.ROMF . L L K ,0 (0, A LK AC,K SK ACkiinf SRL SLL LR SLL LK LR ACS AC? S r .GFT CDRRFSPdKiDlMG ARRAY * 6, AC ACK «(,FT ,A|)DK ) ACMASK ST AC()( IMOFX ,ADI)K ) LM 14, 1?, 1? 14 1 4 , 1 ? , 1 S [ i-i HAIR IIS1N(t ( /- * X ( I 3 ( I -i RIIMF LK , =F SRL AC ,K AC ,R()MF AC , S SLL AC? LK INDFX, SLL AC, 3 ^, AC SR LR LR SR SR SKI. 1. ) *GFT AFFFCTFI) ARRAY WORD MARK SPFCIFIED HIT STORF WORO HACK «RF l.iIRN ) HASH,0 «,hASF MASK, RIIMF MASK, 31 ADDR ,4(0,1 K ,0( O, ADDR L POSITiniM .PRFRARF MASK ) I L SLL HIT « LR L ^-|FMF^M 1NDFX,AC AC 3 L HR fi K. ) OR SKL L hK >:«GFT ) DDK AC'S ACkiinf MASK ,0 AC ADDR, 0(0, ACO( INDF SK SK 1 MASK, 31 ADDR ,4(0,1 • 1 ' »GFT GFT CIIRRFSRONDIMG ARRAY FI.FmFMT Ai: ACK AC *GI-1 H I 1 ROSl 1 ION , /s .PRhMARF MASK IMF A(, ,RI 1^1 K A S K ,0('\C) ADDR ,0(0,1) AC ,D ( 1 iMDFX , = ADDR ) (7F T AFFFC FD ARRAY WDRD 1 ;iill«Ct A-19 PAMSliDKCb STAll-MbMl ASM Din's XR ST AC, MASK AC ,()( INOFX KK. 1^ , ADDR HRASf^ SPeCIFIFI) STORI- WflRI) BACK ) HIT *ReTl)RN STM RALk 1 <+ , 1 ^ , 1 ? 1 ( l)SIN(- «»KASh L K()Mh,=F'l' LR SLL MASK, Af)nK,4(0, L K»0 ((), AODK AC,K ACKilMH SRL AC, SLL AC,/ LR ) MASK,KI)lMl31 L LR SR 3 HASt-,{) I N , AC, SRL MASK,0(AC) L L AODK, 0(1), !?,()( INDHX L A()I)K,H (I), MR BC MASK,b AC AC,K «(;i- AC, 6 ACRIINf: ,HRf-HAR|I I ) POSITION MASK AFFPCTHf) ARRAY WORO- « NOYFS ADDRFSS .CHECK WHFTHFR HIT WAS ON OR NOI 4,Yf-S RdlMf- ,()( SLL R(IMh,l RnMI-,U (0,AI)|)R M Bii OT ) HOT L r *(;t-f ) ,A|-)I)R R KR CDWReSPONOlMC ARRAY hOMI-Mr -i SI SI K AC SLL LK LR SR SR ft, «GFT ) ) (,f-T M- X I 1 0, /i|)|)K 14,1^,12(13) f^(\ll) 1- ' *IF NOT, SET NOYFS TO, 1 RFTOKN YFStSFT NOYFS TO ? «ANI) lA = ) ' ] .•IF ) *RFTOKN ?1 . lA <;iiH« ijIlK !l=l mfii ai' !FI» •« JJ=. r,n 1 fill' fill 'J 11= UHI Ifll Kit KIM A-20 MSF MFXl ?.() SOBKODTINP NtXi ( DATf- lA, MR, IMC, I, J, 7b079 1S/4A/] KIM, K) NFxoonin AMY C kHUJKMS IT IN HdTH hf)RMS A-/R TDK MS K=0 IF IT DdFSN'T FXISI MFxnoo3n MFXOOOAO MFXOnOhO MFXOOOAO MFxnooyo MFX00n80 NF XOOOMO NFxnnioo MFxoni MFX001?0 MFxnni 30 MFxnOl AO MFXOOISO NFXOOl^n MFX000;^0 LIHIKS ( I , J , F(IK KIM ) niMFNSIflN I CROSSING iMhXT & K.-KFhhrKR IA( 1 IM(, FDCtr, Td I Ih f: ) 1=1 JJ = J FIIGF DF ADJACFNT CFLL 1 10 ?n 3(1 AO 40 KKlN=KIN+2 IF(KKIN-4) 2U,;^0,I() KKlN=KKIN-4 Tf)( 3U,A0, bO, 60 ,KIN JJ=JJ-1 (;f) GO ril 70 11=11-1 Gil III 70 MFXOOIHO NFXOOIMO MFXHO^-OO MFXOn?! MFXOn^^O 70 1(1 11=11+1 CHFCKI lA, 1F(K) 80,80,91) CAI.I. 1 1 , JJ ,KK IM,MK ,NC,K MFXn(1?3() ) CALL CHFCK(IA,I,J,KIM,NR,MC,K) MFXOO^'AO MFXOO/'hO NFXOO^<SO MFXOO/^yO MFXOO^'Hn KF1IIK M NFXno^WO WHFN 90 NF xoni 70 .Kl = .l.l+I (,ll ^0 70 i ) 1 ,I = 1 IT I = J,I KI^|=K K IM RFTlIK M FM I DdFSN'l FXIST IM '\ Ub ADJACFMl CFLL,CHFCK THF ClIkKhNI (IMF NF XOfV-iOO MFX0031 (1 IMFXO0-i?O MFX0OH3O NFxoo34n If?. t?SCi If BE' It 1)1-1 NCI |» Gil »IF 1(1 .? w: f,iii j=i IIH 4LI A-21 LFASF SFARCH ?.() IJATR SErAKCHi A ,MK ,l\lCt^LFVL ,(MCiMTK SKHKnilTIIV'F IbOHh 0^/?^/n4 ) Sf-AOOOlO SFAOOO^O FABLF A AMI) GhNEHATFS MCNTK VAl.UfcS EtJDALLY SPACfD HFTWf-FN THF MAXIMDi"! AIM!) MINIMUM VALUBS IIF A. SCANS THfc SFAOnO-^0 SFA00n40 SFAOOO'jO IIIMt-MSIfIN A( MR,MC ,ALFVL( NCN1K ) AMAX = A( 1,1) AM I i\i =AMAX MRMl =MK-1 MCM1=MC-1 SF A 00 100 SFAOOl 10 SFA001?0 SFA00130 SFA00140 SFAOOl bO SFA00160 SFAOOl fO SFAOOl HO SFAOOIMO ?() I , AMAX=A( P ( AM I 1 J)-AMAX I t ) A( I M=A , ( J I )-AMlM , J ) ( [ ( DO SO bO =AM 1=1, 1 ) -10,40,40 ) 40 CIIMIIMOF j = Mf>jTK-l DFL A=( AMAX-AM M ALFVL ^0,20,10 J 40 Til (;(l ?() SFAOOn^O SFAoonvo SFAOOOHO SFAOOOMO Dd 40 I=2tMKMl 1)11 40 J = ?,NCM1 IF( A( U) ) ) / IIM ALFVL(I+1)=ALFVL( I)+OhLIA KFl FMI) llh(M SFA(M)2on SFAOO?! SFAOO^/^O SFAOO? -iO SFA00?40 SFAOO^bO A-22 2.0 STHT SUHKdUTINF STPT IA,NK»NC,K ( LOOKS FOK AN DATE = 7b084 14/00/17 ) MAKKtl) IN lA.IT GlVt^S PREFgRtNCE Tl) BUUNOARY incomplete subtoors are located eirst and their STARTING POINTS ARE (JN THE HOONDARIES. tl)Gh thai ei)r7HS,sn DIMhNSION NRMl=NR-l I A( 1 NCM] =NC-1 1=?. b Of] 10 J=2,NCM1 ST pool 10 INDIA( I , J,2»NR,NC) CALL SEE( IA,K,NOYES GO T(l( 10,90) ,NOYES K= STP00120 STP00130 STP00140 SI POOlbO ) 10 CONTINOE 20 I=NKM1 IE( 1-2 GO TO 30 ) 20,20,30 ST POO 160 SI '->(.) SI POO 140 SI P0020() ST POO? 10 SI P00220 SI P002:-i0 I=2,iMRMl K=INDIA( J, 1,NR,NC CALL SEE( IA,K,NOYES) GO T0{ bO,yO ,NOYES I , ) ) bO CONl INUE S IE(J-2) 60,60,70 60 J=NCM1 GO TO AO 70 HO L= P00260 PO0270 P002H0 SI P0()290 I ST POOIOO ST POO 10 -5 l,2 I P0024() SI SI S ST POO:520 J,L,NR,NC CALL SEE( IA,K,NOYES) GO r(l( 80, VO ,NOYhS HO CONTINUE K=0 90 RFTOKN END K=IIMDI A( I SI P002b() NRM2=NRM1-1 NCM2=NCM1-1 DO HO I=2,NRM2 DO HO J=2,NCM2 f)0 POO 170 STPOOIHO b J=2 40 DO STPOOOIO SI P00020 srpooo^n STP00040 SI POOObO STP0006n STpnno7o STPOOOHO STPOOOMO SI POOIOO , ) ) - • STPOn330 SIP00340 STP00 3b0 ST P 003 60 SI P003 /O STP()n3H0 P003M() SI B-1 APPENDIX B Routine invocation from TROLL. Macros. The two TROLL macros listed below facilitate invoca- tions to CTOUR from the TROLL system environment. (See TROLL * manuals for details in specific commands ). To invoke these macros from any user account, it is necessary to specify the following command after logging ini SEARCH MIT128_MACR0| The macro e^tLIKPLOTS includes computation of likelihood function values at grid points, so that it is only useful for our particular problem, &PLOTS is more general, but it re- quires the function table to be available prior to its invocation. Calling sequences examples are also included and are self-explanatory. (Capital letters correspond to system prompts) Available from the National Bureau of Economic Research, 5^5 Technology Sq . , Cambridge. ; KFMMdi^ ) - IK^^|.||)S I. B-2 PKk- r,(;(iTii SHAKTH HI LL_FliiMr. iM SFAKCH llllTllPT DFVTrp T^^DIO; I 1 I 1 HP IT 1 M T ] I Ak K s I>/1 fiK ' iMfi(,w I n • : " K KRFAM H'f'iH '^ . ?;8"IIKSFRVAT IIIMS >'.KFA(1 >.4"M «>;4 = f-, I I- AK(. |. ) : , N ) ' 1 H ( ) A ^ ) I f,,Fi\m ) ) K l)(i : f/i k A l^' S H ( iO> > ) ; : KFMO " HP F f.7,Kt.4,K't. =MAXS( KHhy IK! 1 f> NFMO VAI.IIF:" 1 ( ( ) ( r>KFAn 0(1 f. ^!i m h^ M K VAt.DFS:" f.FWD h = F X p AMI s; DM = >,^v'iyiMIR ( nil : : MM V/AIJIFS:" KHMD f.kFAn (-.hoYiMiR si-i;ma so. wfli.UFs:" h nil KK4 = FXPAwn( K4, IMDR 5 » KH )H r.RFAIl JlK-' : ^(i"»i;Riot (iiiTriMi w IL'<_Fi)NCT ; I ( '^ KQ ) AC,('.IIKI)TM(.LY . tCiiM-U i\iF ( , ^H ) : ; ) KPRl'^'IA MAXIMUM yilllK r,Hll(iSIK hM n ?, kFAI) K 1 1- VAI.IIF IS Kpi'MFW LF\/FI_S?" m,ii1(i i^wi r,F(.) r,;^ DhlFTF MAI hX'iMFW A f. I F AK(,-( IFVFLS rOfvimiK Yflliw ) 1 , hhlMl) iild f>iFFwi) I.FVFI S nAi^if:": KSl (.A: n (- F : (•>()"FKI 1)1' , I I.F I K '>.,],] rr 1) ADD LFVFI.S hK I Ihl MllllIrS:": : KMiT" iH^-XT Kiil.n: Ki-iFAD KAMF:" l.h-\/i-I.S i,'-<"l|IJ) fihl^lD KhiFXT: siiR nil K -^-Ki-y Dii nil FAK(-( KKK^r = MFDr, 1)11 ?;•'. nil K4. =^Hf,'yr,_Y I III SF I K f I f;SFT n F I- s (^ K I r. KK I I- \/ ppi. K, f, T' F s I I KSFir 'Vi/\K K K KSFT K K IF f. S FT f. KSFV >; ^^ T ) f.4, ( ) ; (, 4, ^H^<-) -( , f, ) ; : : 4 , =1 KFNI) =S KFIMI) I ) ) ; , ; ) =Ai-l(;i>FF(-HI JKLl'II^H IPOI-'S I IIVi-X Y/ M- 1\< I I 1 ) =1 K^ . . hFi\i|) : Ahl IM H(lR /IIMl AF AXIS:" «Kh'> ^(;l|||) RFVFS KIH^-MD '\l' FM -j-imD I- I I ?: Kl I X I : ? X ] : : Kf l.FAi-' >,r t I I F ARI-, F (,(,>) FAI'M ( ARM FAR (;('-< I FAR I F ARI- yjw n II D H FiMD K A f, 1 amf D HD S»-Tr ) ) F AR(,( F r. D I -^ A F AR(;( ^;()'i\/ >;0 PFF'\iviF Kl^l F • f.'^ ) : A KRFAD KTF 1^ I h-D KHf, 9r. ( ARM I , =MliK( ^,Hh4C ) FAKf-,( h KC, IDS ;^ F AKr. K KSFTC. ( ^ A, ( 1 '-^ =^HK4r_x M ^SFT KSF T r, I.I II f. F A;vc, 1)11 ( M SI- '; 1 Ki 1 1 ( ! S I ( ( ) ) 1 ) 1 ) rrf.KHFPF =KS KC ^>^ 1 I -l ) 4 ) - ^, =r, I i R I F/\K(-, I FAR(;( K I. ) I I H A 1 PI ( h ^^ I ) i--. (. ( ;-i 4 ) ) I- 1 I ) ( 1 M-ilD M-MD ) : FAi-;i;( " FAKI-;( ^ F AR(;( m; FA.<; (,( /u^i, KC I 1 ) )+ I M iM D ) + 1 + ] ):, ^ I I D f.Fl-lD X I •sC, '\ KPP I I ; hi /Mi.'.D I \ /I- -^ ( I I'-' llin-, V'vl.ilFS /"'I (IMF 1^1-'. I A', |i I- M I , A) » »: I- B-3 )^ I w k I : ; ' B-4 - ITS HI J M- K K K k 1 1 ( r f 1 , 1 hk I hIkST .''KTH SI i< SH /M<rH Mill _HI 1 M 1 II I II I 1 1 IP •' i I nil K M T 1 h I '•' MM K()'< • H Ak(-,( h s A (; T 'Will M DA I- - X . . A . 1 K'-<<iiiin I h SI IK ( Aku ( >>' . =^h_y '^ . - h(-i_ Y h A'-' (. ? ) I I I I'll M sfI I K I >, ^ S' >,si ^M- s A. I 1 k I-' II I- s r ^Si - >, I ^. I 1 I \ I I) MAi^il-:"; l.l-vi-I.S I oi hi II I HS I " : ; IS MAl-ii-:" f, ' hi-ili ( ( , f, ) : ) X \//\|JI|-S:" M-iMli Y v'Ai.uhs:" M-i\iii r,l li.'1 f -\ : ) { K'^, r.lAMi-:" M IK I Kh K] , . ^) t. M-i.||l : Ik, ( 4 ) ( Kf '^ ) ; M lM| f, ,Mtl I ='i I ) ; ) I 1 --/\i,i,iii-i-( li I I / JKl .iivii ikdi^s 1 1 1 \/ ivy y / M-i-m KS I ^hiMj 1=1 1 . AKI I ; HI III I- IK' I 11''^ A A I. x I S : M-i,l|) II ,',If--l\lli X k Ak 'il-M I , . ( . I I I ! 1 ) 1 ) M /MM k ( ( /\k(, I k I (M > k'^-vf,! I AI.M I . I -i >, so . 1 ( ( / ''i 1 ) ) = f. I I I t. 1 I 1 I I jj 1 ni-l, 1 ^ >, I 'll'l.( Ai-M AT k| ,( ( , I. ( ( M 1 1 K k/\Ki fM » I =f, - K k k -^ S M, =h I. ) ) ^ 'I ) ) I + + f- /'. < ( . ( 1 k 'M-M I ( ) kk ! M I) 1 1 I'll ; k /\k (,( / ) ; ^(. 'O )+ 1 M I'll) ) I I f, kl 'M M-IMI I K -H' I •\ ' M hhh I.F\/I-I.s : Ik I t, M I I A:=>. ^ 1 ] /\ki I . / K . : n h I K 1 I S >, f. >' III. Ij "hh" MJllll Kl-VhS ? Ki r ?.f. I I M Y : f, f ! A'-'K . ^,4. > X ?,M-|C. ^. M.l. I : 1 1 . Ki'-, Ak(-, 1- 1 hi ^'f- )< 1 n .(-'.)- I r.kO i A I ' =Mi (-.il'iV '\k ' \/ *- kki s I ; h/\k'(, 1 ^.f) kMl. Aim ;;'.' AK /Ik! I (M- ?,i-;l-An f, I) !'<; : f, I Sk n- I- i ( Ml n 1 1 i)H-i- M AC(J : 'i)-;i.( I I r I M Ik !i K II >. '- h'l Yi 'S=:i-ihwr, \i' f, I M-IMll ( I ^'-1 >;(ii'Yllllk K MH/\K(;(1). IS i,\ l.l-Vl-LS M,in 1. 1- \/ 1- Ki'i-A|) K : : r >,4"Yi|llk I " : : 1 V, ( • l/\Hl.i-:"): P\/I-I.SV" h'-^i'iMf-iAi M^i-;\n II I) 1 1111/ iMf-Xl Sf-"l I I, >.i-''-Aii I I'M K{i"i-iMl hh- h'^-kt-v 1)1 I "Yi : I 1 , .. III i(,K i-M ' M : I M IK I ( VAIJIH Kill I ^, f, MM- All I ' : Ti Ik . I III ) rilMliilik f.hi-i M-M|ii K. T II ?'t|M(-l.-J ^, K'^ 1)1-1)11 I ( ; =MAXS Yillik 1)1-1. f-[l- V, 1 I ; : .Ml I I- (,k ) ivi^X (I'lllM K'.'^AI) >, 1 ! Ihl I I A r ivi I r".i-lilliSK K I /\kK S I 4 (- : ( I iVl n-i HI- Kh V I- ) l-_Sf-(ii"ll-i^i 1 liMC t 1 ^' I I 1^ C ) I ; I iM 1 /I I' Ikik / h- kik. A •-;!,( h.i k-"l -Ml.!.: ) S'l < k = ^ , v'ALllkS (jii.iliMlk 1 k./\ -I,! ', 1 ) .i, = h I Ai^kllHk k.'>)^i.( ^,-' ) . I-' k N I /\ s |. I J, 1. 1 I I M SI (W\ B-5 TROLL rOf^MAND: do mu TROLL rOMMANP: do s i seq( = = ttma . , seq( ^. / 0. -L ) 0. Oi, 3. , 0. 1 ) TROLL rOMMANn: Sdikplots 'GRID* OR 'fJOHRID* :erid YOUR MU VALUtS:mu YOUR SIGMA SQ. B VALUf-S : s i ema VALUF-S:bb OBSF:RVATinNS:nsob U VALUF;3U0 -.YOUR fiAXlMUM VALUF- IS -lZi>.l25. niOOS^ YOUP roMTOUR L^Vf-LS ArrORHINniY. fJf-U LFVFLS?yps NF-.W LFVf-LS IIAMF:1pv300 ^.Nf-AV hMTfcR SF-.RI f-.S Lt-VF-LS LFV3UU IN OUOThS :"-iZ8 . xzij VARIABLE IN ItORIZONTAL AXISisima -l^b.J -IZb.o -l^J -UU -ijj" TROLL rnrrANn: Apiots 'rRID* OP 'NOHRin' :frrid YOUR TAPLf- rnsobJUU T!^E•. MAXIMUM VALUt IN fJSORjUU IS -l^6.i^'j. YOUR CONTOUR LfiVLLS ACCOROINPLY. CHOOSf-. NtW LhVl-LS?no OLP LhVtLo NAMf-: leviUU YOUR X VALUtJ:mu YOUR Y V/"LUtS:slpma YOUR roNTOUR NAMh nsob 5U0c : '.VARIARLF IN HORIZONTAL AXISrsirrma B-7 C-1 APPENDIX C Program requirements and performance. The memory requirements for the subroutines included in the iso - contour generating package are as follows: Subroutine Bytes CHECK 68k CTOUR 2,552 EDGE 604 INDIA 628 INTER 1,134 MARK, ERASE, SEE 240 NEXT 822 SEARCH 896 STPT 1,088 Total 8,648 As for execution times, we include below the CPU times taken to generate and plot iso - contours in different cases. We measured them for different grid sizes (given by the number of grid nodes) to generate. Actually, the macro ("PLOTS, sind different number of contours these times are execution times for and thus they Include some TROLL overhead. They are measured in seconds. C-2 Grid Size Contours frenerated and plotted 3 25 X 25 50 X 50 15 X 15 100 X 100 References. (1) Eytan Barouch and Gordon M. Kaufman, "Sampling Without Re- placement And Proportional To Size", September, 1974 (2) G. Cottafava and G. Le Moli, "Automatic Contour Map", Co- mmunications of the ACM, July, I969. (3) C. M. Crame, "Contour Plotting For Functions Specified At Nodal Points of an Irregular Mesh Based on an Arbitrary Two Parameter Co-ordinate System", The Computer Journal- Algorithms Supplement, (k) E.M. Greenwalt, "Contours of a Function of Two Variables", University of Texas, I968. 143 w no.790- 75 Donovan, John /Use of virtual machines T-J5 ""liiiiiiiiiiiilir ODD 7D4 TOflO 3 l'=14 HD28.M414 no.791- 75 Harris, Reuben/A multitiimensional appr 731703 0»BKS Q003771.f ODD TOflD 3 flbb ail T-J5 143 w no.792- 75 Nam, Sang Woo/Banking structure and 000195"' 724734 D*BKS p ^ T-J5 Katz, w 143 Ralph. no.793- 75 /Job enrichment ODD IDflO 3 tm ODD TDfiD 3 ST4 : t.41 SbO HD28.IVI414 no.794- 75 Cook Johnson. /Toward a theory on high 724730 D*BKS iliiiiii 3 TDflO bm DDD Mbl HD28.M414 no.795-75 Andreu, Rafael/An iso-contour plotting '" 724727 3 D*BKS TDflD . . ,00019 DDD bMl M2D