001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.math4.legacy.stat.interval; 018 019import org.apache.commons.math4.legacy.exception.NotPositiveException; 020import org.apache.commons.math4.legacy.exception.NotStrictlyPositiveException; 021import org.apache.commons.math4.legacy.exception.NumberIsTooLargeException; 022import org.apache.commons.math4.legacy.exception.OutOfRangeException; 023 024/** 025 * Interface to generate confidence intervals for a binomial proportion. 026 * 027 * @see <a 028 * href="http://en.wikipedia.org/wiki/Binomial_proportion_confidence_interval">Binomial 029 * proportion confidence interval (Wikipedia)</a> 030 * @since 3.3 031 */ 032public interface BinomialConfidenceInterval { 033 034 /** 035 * Create a confidence interval for the true probability of success 036 * of an unknown binomial distribution with the given observed number 037 * of trials, successes and confidence level. 038 * <p> 039 * Preconditions: 040 * <ul> 041 * <li>{@code numberOfTrials} must be positive</li> 042 * <li>{@code numberOfSuccesses} may not exceed {@code numberOfTrials}</li> 043 * <li>{@code confidenceLevel} must be strictly between 0 and 1 (exclusive)</li> 044 * </ul> 045 * 046 * @param numberOfTrials number of trials 047 * @param numberOfSuccesses number of successes 048 * @param confidenceLevel desired probability that the true probability of 049 * success falls within the returned interval 050 * @return Confidence interval containing the probability of success with 051 * probability {@code confidenceLevel} 052 * @throws NotStrictlyPositiveException if {@code numberOfTrials <= 0}. 053 * @throws NotPositiveException if {@code numberOfSuccesses < 0}. 054 * @throws NumberIsTooLargeException if {@code numberOfSuccesses > numberOfTrials}. 055 * @throws OutOfRangeException if {@code confidenceLevel} is not in the interval {@code (0, 1)}. 056 */ 057 ConfidenceInterval createInterval(int numberOfTrials, int numberOfSuccesses, double confidenceLevel) 058 throws NotStrictlyPositiveException, NotPositiveException, 059 NumberIsTooLargeException, OutOfRangeException; 060}