@Test public void fractionOfData() throws Exception { Double output = testStats95.fractionOfData(5, 2, 4, 0, -0.5); assertThat("lower bound: need more data", output, IsCloseTo.closeTo(0.9231127, precision)); Double output2 = testStats95.fractionOfData(5, 2, 4, 3, -0.5); assertThat("independent of actions_2", output2, equalTo(output)); output = testStats95.fractionOfData(5, 2, 4, 0, -0.7); assertThat("lower bound: have enough data", output, IsCloseTo.closeTo(6.2222297, precision)); output2 = testStats95.fractionOfData(5, 2, 4, 3, -0.7); assertThat("independent of actions_2", output2, equalTo(output)); output = testStats95.fractionOfData(5, 2, 4, 0, 0.2); assertThat("upper bound: need more data", output, IsCloseTo.closeTo(0.1183263, precision)); output2 = testStats95.fractionOfData(5, 2, 4, 3, 0.2); assertThat("independent of actions_2", output2, equalTo(output)); output = testStats95.fractionOfData(5, 2, 4, 0, 0.5); assertThat("upper bound: have enough data", output, IsCloseTo.closeTo(3.174607, precision)); output2 = testStats95.fractionOfData(5, 2, 4, 3, 0.5); assertThat("independent of actions_2", output2, equalTo(output)); DistinguishableEffectSize output3 = testStats95.distinguishableEffectSizes(5, 2, 4, 0); output = testStats95.fractionOfData(5, 2, 4, 0, output3.getNegativeEffectSize()); assertThat("lower bound: boundary", output, IsCloseTo.closeTo(1.0, precision)); output = testStats95.fractionOfData(5, 2, 4, 0, output3.getPositiveEffectSize()); assertThat("upper bound: boundary", output, IsCloseTo.closeTo(1.0, precision)); output = testStats95.fractionOfData(0, 0, 1, 0, 0.1); assertThat("0 impressions returns NaN", output, is(NaN)); output = testStats95.fractionOfData(1, 1, 0, 0, 0.1); assertThat("0 impressions returns 0", output, IsCloseTo.closeTo(0.0, precision)); output = testStats95.fractionOfData(0, 0, 0, 0, 0.1); assertThat("0 impressions returns NaN", output, is(NaN)); }
@Override public Double fractionOfData(final long number_impressions_1, final long number_actions_1, final long number_impressions_2, final long number_actions_2, final double effect_size) { inputValidation(number_impressions_1, number_actions_1, number_impressions_2); if (effect_size < -1.0 || effect_size > 1.0) { throw new IllegalArgumentException("Effect size must be in the interval [-1, 1]."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double rate_1 = 1.0 * number_actions_1 / number_impressions_1; double rate_2 = rate_1 - effect_size; return 1 / ((rate_1 * (1 - rate_1) / number_impressions_1 + rate_2 * (1 - rate_2) / number_impressions_2) * zval * zval / effect_size / effect_size); }
NormalApproxMetric extends BinomialMetric { @Override public Double fractionOfData(final long number_impressions_1, final long number_actions_1, final long number_impressions_2, final long number_actions_2, final double effect_size) { inputValidation(number_impressions_1, number_actions_1, number_impressions_2); if (effect_size < -1.0 || effect_size > 1.0) { throw new IllegalArgumentException("Effect size must be in the interval [-1, 1]."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double rate_1 = 1.0 * number_actions_1 / number_impressions_1; double rate_2 = rate_1 - effect_size; return 1 / ((rate_1 * (1 - rate_1) / number_impressions_1 + rate_2 * (1 - rate_2) / number_impressions_2) * zval * zval / effect_size / effect_size); } }
NormalApproxMetric extends BinomialMetric { @Override public Double fractionOfData(final long number_impressions_1, final long number_actions_1, final long number_impressions_2, final long number_actions_2, final double effect_size) { inputValidation(number_impressions_1, number_actions_1, number_impressions_2); if (effect_size < -1.0 || effect_size > 1.0) { throw new IllegalArgumentException("Effect size must be in the interval [-1, 1]."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double rate_1 = 1.0 * number_actions_1 / number_impressions_1; double rate_2 = rate_1 - effect_size; return 1 / ((rate_1 * (1 - rate_1) / number_impressions_1 + rate_2 * (1 - rate_2) / number_impressions_2) * zval * zval / effect_size / effect_size); } NormalApproxMetric(final double conf_level);  NormalApproxMetric(final double conf_level, final double max_decisions); }
NormalApproxMetric extends BinomialMetric { @Override public Double fractionOfData(final long number_impressions_1, final long number_actions_1, final long number_impressions_2, final long number_actions_2, final double effect_size) { inputValidation(number_impressions_1, number_actions_1, number_impressions_2); if (effect_size < -1.0 || effect_size > 1.0) { throw new IllegalArgumentException("Effect size must be in the interval [-1, 1]."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double rate_1 = 1.0 * number_actions_1 / number_impressions_1; double rate_2 = rate_1 - effect_size; return 1 / ((rate_1 * (1 - rate_1) / number_impressions_1 + rate_2 * (1 - rate_2) / number_impressions_2) * zval * zval / effect_size / effect_size); } NormalApproxMetric(final double conf_level);  NormalApproxMetric(final double conf_level, final double max_decisions); @Override Estimate estimateRate(final long number_impressions, final long number_actions); @Override Estimate estimateRateDifference(final long number_impressions_1, final long number_actions_1,
                                           final long number_impressions_2, final long number_actions_2); @Override DistinguishableEffectSize distinguishableEffectSizes(final long number_impressions_1,
                                                                final long number_actions_1,
                                                                final long number_impressions_2,
                                                                final long number_actions_2); @Override Double fractionOfData(final long number_impressions_1, final long number_actions_1,
                                 final long number_impressions_2, final long number_actions_2,
                                 final double effect_size); @Override Long predictedDataNeeded(final double rate, final double allocation_percent_1,
                                    final double allocation_percent_2, final double effect_size); }
NormalApproxMetric extends BinomialMetric { @Override public Double fractionOfData(final long number_impressions_1, final long number_actions_1, final long number_impressions_2, final long number_actions_2, final double effect_size) { inputValidation(number_impressions_1, number_actions_1, number_impressions_2); if (effect_size < -1.0 || effect_size > 1.0) { throw new IllegalArgumentException("Effect size must be in the interval [-1, 1]."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double rate_1 = 1.0 * number_actions_1 / number_impressions_1; double rate_2 = rate_1 - effect_size; return 1 / ((rate_1 * (1 - rate_1) / number_impressions_1 + rate_2 * (1 - rate_2) / number_impressions_2) * zval * zval / effect_size / effect_size); } NormalApproxMetric(final double conf_level);  NormalApproxMetric(final double conf_level, final double max_decisions); @Override Estimate estimateRate(final long number_impressions, final long number_actions); @Override Estimate estimateRateDifference(final long number_impressions_1, final long number_actions_1,
                                           final long number_impressions_2, final long number_actions_2); @Override DistinguishableEffectSize distinguishableEffectSizes(final long number_impressions_1,
                                                                final long number_actions_1,
                                                                final long number_impressions_2,
                                                                final long number_actions_2); @Override Double fractionOfData(final long number_impressions_1, final long number_actions_1,
                                 final long number_impressions_2, final long number_actions_2,
                                 final double effect_size); @Override Long predictedDataNeeded(final double rate, final double allocation_percent_1,
                                    final double allocation_percent_2, final double effect_size);  }