Pricing { public static Double pricingFactor(double from, double to) { if (from <= 0.5 || from >= 1) return null; if (to <= 0.5 || to >= 1) return null; if (from == to) return 1.0; boolean reverse = (from > to); if (reverse) { double temp = to; to = from; from = temp; } int minK = 1; double prob = probabilityCorrect(from, minK); while (prob < to) { minK += 2; prob = probabilityCorrect(from, minK); } double l = Stat.logoggs(probabilityCorrect(from, minK - 2)); double h = Stat.logoggs(probabilityCorrect(from, minK)); double t = Stat.logoggs(to); double x = 2 * (t - l) / (h - l); double result = minK - 2 + x; if (reverse) { result = 1 / result; } return result; }  static double getNormalizedP_simple(double q_exp); static double getNormalizedQexp_simple(double p); static Double probabilityCorrect(Double p, Integer k); static Double pricingFactor(double from, double to); static void main(String[] args);  }
@Test public final void testPricingFactor() { for (double from=0; from<1.0; from+=0.05) { for (double to=0; to<=1.0; to+=0.05) { Double pricingFactor = Pricing.pricingFactor(new Double(from), new Double(to)); assertTrue(pricingFactor==null||pricingFactor>=0); } } }