Friday, May 25, 2007

1 billion queries

Prior to a life in finance, I had a brief stint in root cause analysis for diseases for the Department of the Navy (NMIC).
They problem was always the same- a ton of variables and some measure of sickness. For example you might have weight, age, blood pressure etc and on the right hand side you have a weighted value of sickness (visits, stage of disease etc). If I had q and arthur back then, I think we could have cured cancer. The code below does 1 billion queries in a couple of seconds, finding all 3 variable combinations. For example if the variables are `a`b`c, and the weighted death value is D then an example output is

if a>2,b<3,d>5 then the sum of D is 2345


n:500000
m:5
t:([]a:n?1.0;b:n?1.0;c:n?1.0;d:n?1.0;e:n?1.0)
il:`b`c`d`e //variable list il (independent list)

k)f3:{s2'+\(m;0N)#@[(m*m*m)#0.0;m/:(x;(m-1)-y;z);+;t.a]}
k)u:m .q.xrank't il
k)r3:{u f3[x]\:/:u}':u

No comments: