A general computer program for the Bell detection loophole
  The difference between ideal experiments to test Bell's weak nonlocality and the real experiments leads to loopholes. Ideal experiments involve either inequalities (Bell) or equalities (Greenberger, Horne, Zeilinger). Every real experiment has its own critical inequalities, which are almost all more complicated than the corresponding ideal inequalities and equalities. If one of these critical inequalities is violated, then the detection loophole is closed, with no further assumptions. If all the critical inequalities are satisfied, then it remains open, unless further assumptions are made. The computer program described here and published on the website http://www.strings.ph.qmw.ac.uk/QI/main.htm obtains the critical inequalities for any real experiment, given the number of allowed settings of the angles and the corresponding possible output signals for a single run. Given all the necessary conditional probabilities or rates, it tests whether all these inequalities are satisfied. 
Roberto M. Basoalto and Ian C. Percival