@Test(expected = IllegalArgumentException.class) public void estimateRateInputs2() throws Exception { testStats95.estimateRate(5, -1); }
@Override public Estimate estimateRate(final long number_impressions, final long number_actions) { if (number_impressions < 0) { throw new IllegalArgumentException("Number of unique impressions must be nonnegative."); } if (number_actions < 0) { throw new IllegalArgumentException("Number of unique actions must be nonnegative."); } if (number_actions > number_impressions) { throw new IllegalArgumentException("Number of unique actions cannot exceed number of unique impressions."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double mid = (number_actions + 0.5 * zval * zval) / (number_impressions + zval * zval); double confint = zval * sqrt(mid * (1 - mid) / (number_impressions + zval * zval)); return new Estimate.Builder().withEstimate(1.0 * number_actions / number_impressions) .withLowerBound(mid - confint) .withUpperBound(mid + confint).build(); }
NormalApproxMetric extends BinomialMetric { @Override public Estimate estimateRate(final long number_impressions, final long number_actions) { if (number_impressions < 0) { throw new IllegalArgumentException("Number of unique impressions must be nonnegative."); } if (number_actions < 0) { throw new IllegalArgumentException("Number of unique actions must be nonnegative."); } if (number_actions > number_impressions) { throw new IllegalArgumentException("Number of unique actions cannot exceed number of unique impressions."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double mid = (number_actions + 0.5 * zval * zval) / (number_impressions + zval * zval); double confint = zval * sqrt(mid * (1 - mid) / (number_impressions + zval * zval)); return new Estimate.Builder().withEstimate(1.0 * number_actions / number_impressions) .withLowerBound(mid - confint) .withUpperBound(mid + confint).build(); } }
NormalApproxMetric extends BinomialMetric { @Override public Estimate estimateRate(final long number_impressions, final long number_actions) { if (number_impressions < 0) { throw new IllegalArgumentException("Number of unique impressions must be nonnegative."); } if (number_actions < 0) { throw new IllegalArgumentException("Number of unique actions must be nonnegative."); } if (number_actions > number_impressions) { throw new IllegalArgumentException("Number of unique actions cannot exceed number of unique impressions."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double mid = (number_actions + 0.5 * zval * zval) / (number_impressions + zval * zval); double confint = zval * sqrt(mid * (1 - mid) / (number_impressions + zval * zval)); return new Estimate.Builder().withEstimate(1.0 * number_actions / number_impressions) .withLowerBound(mid - confint) .withUpperBound(mid + confint).build(); } NormalApproxMetric(final double conf_level);  NormalApproxMetric(final double conf_level, final double max_decisions); }
NormalApproxMetric extends BinomialMetric { @Override public Estimate estimateRate(final long number_impressions, final long number_actions) { if (number_impressions < 0) { throw new IllegalArgumentException("Number of unique impressions must be nonnegative."); } if (number_actions < 0) { throw new IllegalArgumentException("Number of unique actions must be nonnegative."); } if (number_actions > number_impressions) { throw new IllegalArgumentException("Number of unique actions cannot exceed number of unique impressions."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double mid = (number_actions + 0.5 * zval * zval) / (number_impressions + zval * zval); double confint = zval * sqrt(mid * (1 - mid) / (number_impressions + zval * zval)); return new Estimate.Builder().withEstimate(1.0 * number_actions / number_impressions) .withLowerBound(mid - confint) .withUpperBound(mid + confint).build(); } 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 Estimate estimateRate(final long number_impressions, final long number_actions) { if (number_impressions < 0) { throw new IllegalArgumentException("Number of unique impressions must be nonnegative."); } if (number_actions < 0) { throw new IllegalArgumentException("Number of unique actions must be nonnegative."); } if (number_actions > number_impressions) { throw new IllegalArgumentException("Number of unique actions cannot exceed number of unique impressions."); } double zval = DecisionAdjuster.scaledZ(confidenceLevel, maxDecisions); double mid = (number_actions + 0.5 * zval * zval) / (number_impressions + zval * zval); double confint = zval * sqrt(mid * (1 - mid) / (number_impressions + zval * zval)); return new Estimate.Builder().withEstimate(1.0 * number_actions / number_impressions) .withLowerBound(mid - confint) .withUpperBound(mid + confint).build(); } 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);  }