bundles / scipy 1.17.1 / scipy / stats / _binomtest / binomtest
function
scipy.stats._binomtest:binomtest
source: /scipy/stats/_binomtest.py :203
Signature
def binomtest ( k , n , p = 0.5 , alternative = two-sided ) Summary
Perform a test that the probability of success is p.
Extended Summary
The binomial test [1] is a test of the null hypothesis that the probability of success in a Bernoulli experiment is p.
Details of the test can be found in many texts on statistics, such as section 24.5 of [2].
Parameters
k: intThe number of successes.
n: intThe number of trials.
p: float, optionalThe hypothesized probability of success, i.e. the expected proportion of successes. The value must be in the interval
0 <= p <= 1. The default value isp = 0.5.alternative: {'two-sided', 'greater', 'less'}, optionalIndicates the alternative hypothesis. The default value is 'two-sided'.
Returns
result: `~scipy.stats._result_classes.BinomTestResult` instanceThe return value is an object with the following attributes:
k
k
n
n
alternative
alternative
statistic
statistic
pvalue
pvalue
The object has the following methods:
proportion_ci(confidence_level=0.95, method='exact') :
Compute the confidence interval for
statistic.
Notes
Array API Standard Support
binomtest has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.
==================== ==================== ==================== Library CPU GPU ==================== ==================== ==================== NumPy ✅ n/a CuPy n/a ⛔ PyTorch ⛔ ⛔ JAX ⛔ ⛔ Dask ⛔ n/a ==================== ==================== ====================
See
dev-arrayapifor more information.
Examples
from scipy.stats import binomtest
✓result = binomtest(3, n=15, p=0.1, alternative='greater')
✓result.pvalue
✗result.statistic
✓result.proportion_ci(confidence_level=0.95)
✓Aliases
-
scipy.stats.binomtest