one_proportion_z_test
Test whether an observed proportion differs from a hypothesized value using a z-test, returning z-statistic, p-value, confidence interval, and assumption warnings.
Instructions
Test whether an observed proportion (successes out of n) differs from a hypothesized proportion p0 -- e.g. "is this coin fair (p0=0.5) given 55 heads in 100 flips?" Uses the normal approximation, which degrades for small n or p0 near 0 or 1; a warning is included when that assumption looks shaky. Returns the z-statistic, two-tailed p-value, a confidence interval for the true proportion, a citation, and warnings.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| n | Yes | total number of trials/observations | |
| p0 | Yes | the hypothesized true proportion to test against, in [0, 1] | |
| alpha | No | significance level for the test (and any confidence interval); default 0.05 | |
| successes | Yes | number of successes observed |