I did a lot of APL thirty years ago, and recently I began to try to learn J. It is difficult, but worth while.
For example when I computed the mean value (m) and the standard deviation (s) of the 'German tank problem' distribution, (see http://en.wikipedia.org/wiki/German_tank_problem), I encountered the following problem. The number of items in the sample is x, and the maximum sequence number in the sample is y. Then the mean number of items in the population is m=.(y-1)*(x-1)%(x-2) or, using a J facility m=.(y-1)*%/x - 1 2 and the standard deviation is s=.%:((*/y - 1 2)*%/x - 1 3)+m*1-m or, using the hook (m*1-m) === (*-.)m s=.%:((*/y - 1 2)*%/x - 1 3)+(*-.)m It works! Then I make a dyadic verb, ms1, computing mu,sigma ms1 =. 4 : 'm,%:((*/y-1 2)*%/x-1 3)+(*-.)m=.(y-1)*%/x-1 2' test: 6 ms1 14 16.25 3.49106 When I try to simplify by the hook (m,f m) === (,f)m ms2 =. 4 : '(,(%:((*/y-1 2)*%/x-1 3)+(*-.)))(y-1)*%/x-1 2' it works no more: 6 ms2 14 16.25 1.16634 What do I do wrong? Regards, Bo Jacoby Trænger du til at se det store billede? Kelkoo giver dig gode tilbud på LCD TV! Se her http://dk.yahoo.com/r/pat/lcd ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
