Here is one approach: Mn=: 13 :'y H.(-x+1e_7)2'"1 M=: 13 :'|:y Mn 1 2 3,&>/-i.1+y' ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y'
I'm not sure if that helps... (I am also slightly dubious about that whole +1e_7 epsilon thing.) -- Raul On Thu, Jul 7, 2016 at 4:53 PM, 'Bo Jacoby' via Programming <[email protected]> wrote: > I am estimating the number of known answers (x) in a multiple choice test, > knowing the number of correctly (y) and incorrectly (n-y) answered > questions. > The computation shows that N=10 and y=8 gives x=5±2. > I would like to compress the three lines defining M0, M1 and M2 into at > single line. > Thank you! > Bo. > M0=. 13 : '(1,-x)H.(-y+1e_7)2' > > M1=. 13 : '(2,-x)H.(-y+1e_7)2' > M2=. 13 : '(3,-x)H.(-y+1e_7)2' > M =. 13 : '>(i.>:y)(M0,M1,M2)&.>y' > ms=. 13 : '(<:a),:%:a*(+:b)->:a[''a b''=.|:2%~/\"1 M y' > 3":(i.@>:,ms) 10 > 0 1 2 3 4 5 6 7 8 9 10 > 0 0 0 1 1 2 3 4 5 7 9 > 0 0 1 1 1 1 2 2 2 2 1 > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
