Empirical tests of scientific realism: a quantitative framework