{"id":6797,"date":"2026-08-18T14:25:10","date_gmt":"2026-08-18T19:25:10","guid":{"rendered":"https:\/\/ykim.synology.me\/wordpress\/?p=6797"},"modified":"2026-11-26T22:37:32","modified_gmt":"2026-11-27T04:37:32","slug":"ceiling-of-the-classical-z-score","status":"publish","type":"post","link":"https:\/\/ykim.synology.me\/wordpress\/ceiling-of-the-classical-z-score-6797\/","title":{"rendered":"Ceiling of the Classical z-Score"},"content":{"rendered":"\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/yBarn1\/Images\/main\/storefronts\/heb-plus-storefront-dusk.jpg\" alt=\"\" style=\"width:auto;height:500px\"\/><\/figure>\n\n\n<p><div class=\"github-readme-container markdown-body\"><div id=\"file\" class=\"md\" data-path=\"ZScore\/z-score-ceiling.md\"><article class=\"markdown-body entry-content container-lg\" itemprop=\"text\"><div class=\"markdown-heading\" dir=\"auto\"><h1 class=\"heading-element\" dir=\"auto\">Ceiling of the Classical z-Score<\/h1><a id=\"user-content-ceiling-of-the-classical-z-score\" class=\"anchor\" aria-label=\"Permalink: Ceiling of the Classical z-Score\" href=\"#ceiling-of-the-classical-z-score\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Version 7 | Created: 2026-08-18 | Updated: 2026-11-07 13:46 UTC<\/p>\n<ul dir=\"auto\">\n<li><a href=\"#1-scope\">1. Scope<\/a><\/li>\n<li><a href=\"#2-bound\">2. Bound<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#21-statement\">2.1. Statement<\/a><\/li>\n<li><a href=\"#22-derivation\">2.2. Derivation<\/a><\/li>\n<li><a href=\"#23-equality\">2.3. Equality<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#3-consequence\">3. Consequence<\/a>\n<ul dir=\"auto\">\n<li><a href=\"#31-cut-offs-a-small-sample-cannot-reach\">3.1. Cut-offs a Small Sample Cannot Reach<\/a><\/li>\n<li><a href=\"#32-divisor-of-the-scale\">3.2. Divisor of the Scale<\/a><\/li>\n<\/ul>\n<\/li>\n<li><a href=\"#references\">References<\/a><\/li>\n<li><a href=\"#appendix-a-terminology\">Appendix A. Terminology<\/a><\/li>\n<li><a href=\"#appendix-b-reference-implementation\">Appendix B. Reference Implementation<\/a><\/li>\n<li><a href=\"#appendix-c-worked-example\">Appendix C. Worked Example<\/a><\/li>\n<\/ul>\n<blockquote>\n<p dir=\"auto\">A note on the largest absolute z-score a sample of a given size can produce, the derivation of\nthat bound, and what it costs a rule that flags observations by comparing a z-score against a\nfixed cut-off.<\/p>\n<\/blockquote>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">1. Scope<\/h2><a id=\"user-content-1-scope\" class=\"anchor\" aria-label=\"Permalink: 1. Scope\" href=\"#1-scope\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The most common way to call an observation extreme is to divide its deviation from the mean by\nthe standard deviation and compare the result against a cut-off. Both the centre and the scale\nin that ratio come from the same sample the observation belongs to, so the observation under test\nsits inside its own denominator.<\/p>\n<p dir=\"auto\">That self-reference has a consequence that is easy to miss. The ratio has a ceiling, and the\nceiling is fixed by the sample size alone. For a small enough sample it falls below the cut-off,\nand the rule then flags nothing, whatever the data are.<\/p>\n<p dir=\"auto\">This document gives that ceiling, derives it, and shows what it costs a rule at a fixed cut-off.\nIt is about the arithmetic of the score, not about what should be done with an outlier once one\nis found.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">2. Bound<\/h2><a id=\"user-content-2-bound\" class=\"anchor\" aria-label=\"Permalink: 2. Bound\" href=\"#2-bound\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">2.1. Statement<\/h3><a id=\"user-content-21-statement\" class=\"anchor\" aria-label=\"Permalink: 2.1. Statement\" href=\"#21-statement\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Write <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$x_1, \\ldots, x_n$<\/math-renderer> for the sample, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$\\bar{x}$<\/math-renderer> for its mean, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$s$<\/math-renderer> for its standard deviation,\nand <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$z_i = (x_i - \\bar{x}) \/ s$<\/math-renderer> for the classical score of observation <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$i$<\/math-renderer>.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$$\\max_i \\left| z_i \\right| \\le \\frac{n-1}{\\sqrt{n}}$$<\/math-renderer><\/p>\n<p dir=\"auto\">The bound is due to Shiffler (1988). It is arithmetic rather than a property of any sample, and\nit holds for every set of <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n$<\/math-renderer> numbers.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">2.2. Derivation<\/h3><a id=\"user-content-22-derivation\" class=\"anchor\" aria-label=\"Permalink: 2.2. Derivation\" href=\"#22-derivation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The derivation needs two identities. Deviations from the mean sum to zero, and the sample\nstandard deviation is defined from their squares.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$$\\sum_{j=1}^{n} \\left( x_j - \\bar{x} \\right) = 0, \\qquad \\sum_{j=1}^{n} \\left( x_j - \\bar{x} \\right)^2 = (n-1)s^2$$<\/math-renderer><\/p>\n<p dir=\"auto\">Fix one observation and write <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$d = x_i - \\bar{x}$<\/math-renderer>. The first identity says the other <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n-1$<\/math-renderer>\ndeviations sum to <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$-d$<\/math-renderer>. By the Cauchy-Schwarz inequality, <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n-1$<\/math-renderer> numbers whose sum is <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$-d$<\/math-renderer> have a\nsum of squares of at least <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$d^2 \/ (n-1)$<\/math-renderer>. Splitting the second identity at observation <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$i$<\/math-renderer> and\napplying that lower bound gives the result in one line.<\/p>\n<p dir=\"auto\"><math-renderer class=\"js-display-math\" style=\"display: block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$$(n-1)s^2 = d^2 + \\sum_{j \\ne i} \\left( x_j - \\bar{x} \\right)^2 \\ \\ge \\ d^2 + \\frac{d^2}{n-1} \\ = \\ \\frac{n}{n-1} d^2$$<\/math-renderer><\/p>\n<p dir=\"auto\">Rearranging gives <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$d^2 \\le (n-1)^2 s^2 \/ n$<\/math-renderer>, and dividing by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$s$<\/math-renderer> leaves the bound.<\/p>\n<p dir=\"auto\">Only the second identity involves <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$s$<\/math-renderer>, so it is the one that carries the self-reference of\nsection 1. That identity alone already bounds the score: drop the sum over <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$j \\ne i$<\/math-renderer> from the\ndisplay and <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$d^2 \\le (n-1)s^2$<\/math-renderer> remains. The self-reference is therefore what makes the score\nbounded at all, and the zero sum of the deviations is what sharpens the constant to\n<math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$(n-1)\/\\sqrt{n}$<\/math-renderer>.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">2.3. Equality<\/h3><a id=\"user-content-23-equality\" class=\"anchor\" aria-label=\"Permalink: 2.3. Equality\" href=\"#23-equality\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The Cauchy-Schwarz step is an equality when the <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n-1$<\/math-renderer> deviations other than <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$d$<\/math-renderer> are all equal. A\nsample of that shape is one observation set apart from <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n-1$<\/math-renderer> tied ones, and it reaches the bound\nexactly.<\/p>\n<p dir=\"auto\">The ceiling is therefore attained rather than approached, which is what makes it worth stating. A\nbound no sample comes near would say little about the rules built on the score.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">3. Consequence<\/h2><a id=\"user-content-3-consequence\" class=\"anchor\" aria-label=\"Permalink: 3. Consequence\" href=\"#3-consequence\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.1. Cut-offs a Small Sample Cannot Reach<\/h3><a id=\"user-content-31-cut-offs-a-small-sample-cannot-reach\" class=\"anchor\" aria-label=\"Permalink: 3.1. Cut-offs a Small Sample Cannot Reach\" href=\"#31-cut-offs-a-small-sample-cannot-reach\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">A rule that flags an observation when <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$\\left| z_i \\right| \\gt k$<\/math-renderer> can only fire in a sample whose\nceiling sits above <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$k$<\/math-renderer>. In any smaller sample the rule is inert.<\/p>\n<p dir=\"auto\"><strong>Table 1. The ceiling at several sample sizes<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Sample size n<\/th>\n<th>Largest attainable absolute z<\/th>\n<th>A rule at 3.5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>10<\/td>\n<td>2.8460<\/td>\n<td>Can never fire<\/td>\n<\/tr>\n<tr>\n<td>14<\/td>\n<td>3.4744<\/td>\n<td>Can never fire<\/td>\n<\/tr>\n<tr>\n<td>15<\/td>\n<td>3.6148<\/td>\n<td>Can fire, barely<\/td>\n<\/tr>\n<tr>\n<td>20<\/td>\n<td>4.2485<\/td>\n<td>Can fire<\/td>\n<\/tr>\n<tr>\n<td>54<\/td>\n<td>7.2124<\/td>\n<td>Can fire<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">The smallest sample a rule can fire in follows from its cut-off. A cut-off of 3 needs at least 11\nobservations, and a cut-off of 3.5 needs at least 15. Test fourteen observations at 3.5 and the\nanswer is settled before the data are read.<\/p>\n<p dir=\"auto\">The danger is that nothing says so. No part of the output distinguishes a sample carrying no\nextreme observation from a sample too small for the rule to report one.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h3 class=\"heading-element\" dir=\"auto\">3.2. Divisor of the Scale<\/h3><a id=\"user-content-32-divisor-of-the-scale\" class=\"anchor\" aria-label=\"Permalink: 3.2. Divisor of the Scale\" href=\"#32-divisor-of-the-scale\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The constant <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$(n-1)\/\\sqrt{n}$<\/math-renderer> is written for the sample standard deviation, which divides the sum\nof squares by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n-1$<\/math-renderer>. Dividing by <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n$<\/math-renderer> instead gives a smaller <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$s$<\/math-renderer> and a larger score, and the same\nderivation then yields <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$\\sqrt{n-1}$<\/math-renderer> as the sharp bound.<\/p>\n<p dir=\"auto\">The two differ by enough to matter near a cut-off. A score computed with <code>numpy.std<\/code> at its\ndefault <code>ddof=0<\/code> is measured against <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$\\sqrt{n-1}$<\/math-renderer> rather than <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$(n-1)\/\\sqrt{n}$<\/math-renderer>, so the size at\nwhich a rule becomes capable of firing shifts with a setting that is easy to leave unexamined.<\/p>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">References<\/h2><a id=\"user-content-references\" class=\"anchor\" aria-label=\"Permalink: References\" href=\"#references\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\"><a id=\"user-content-ref-1\"><\/a>\n[1] Shiffler, R. E. (1988). <a href=\"https:\/\/doi.org\/10.1080\/00031305.1988.10475530\" rel=\"nofollow\">Maximum Z Scores and Outliers<\/a>. <em>The American Statistician<\/em>, 42(1), 79\u201380.<br>\n<a id=\"user-content-ref-2\"><\/a>\n[2] Barnett, V., &amp; Lewis, T. (1994). <em>Outliers in Statistical Data<\/em>, 3rd edition. Wiley, Chichester. <a href=\"https:\/\/www.wiley.com\" rel=\"nofollow\">https:\/\/www.wiley.com<\/a>. ISBN 978-0-471-93094-5.<\/p>\n<hr>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix A. Terminology<\/h2><a id=\"user-content-appendix-a-terminology\" class=\"anchor\" aria-label=\"Permalink: Appendix A. Terminology\" href=\"#appendix-a-terminology\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<ul dir=\"auto\">\n<li><strong>ceiling<\/strong> \u2014 The largest value a statistic can take over all samples of a given size, as opposed to a critical value, which is a cut-off chosen to control an error rate.<\/li>\n<li><strong>degrees of freedom correction (ddof)<\/strong> \u2014 The amount subtracted from the sample size to form the divisor of the sum of squared deviations. A correction of 1 gives the sample standard deviation and a correction of 0 gives the population form.<\/li>\n<li><strong>outlier<\/strong> \u2014 An observation that is inconsistent with the distribution the rest of the sample follows, in the sense used by Barnett and Lewis (1994). The label concerns consistency with a model and does not by itself establish that the observation is wrong.<\/li>\n<li><strong>z-score<\/strong> \u2014 The deviation of an observation from the sample mean, divided by the sample standard deviation.<\/li>\n<\/ul>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix B. Reference Implementation<\/h2><a id=\"user-content-appendix-b-reference-implementation\" class=\"anchor\" aria-label=\"Permalink: Appendix B. Reference Implementation\" href=\"#appendix-b-reference-implementation\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">The block below is <code>z_score_ceiling.py<\/code>, in the folder of this document. It is that file as\nwritten, without the module docstring and the <code>if __name__ == '__main__':<\/code> guard.<\/p>\n<p dir=\"auto\">The file holds the score and its ceiling and nothing else. Tabulating them and drawing them are\nleft to whatever calls it.<\/p>\n<div class=\"highlight highlight-source-python notranslate position-relative overflow-auto\" dir=\"auto\" data-snippet-clipboard-copy-content=\"# Math\/ZScore\/z_score_ceiling.py\n__author__ = 'yRocket'\n__version__ = &quot;0.0.0.2026.8.18&quot;  # Semantic Versioning: Major.Minor.Patch.Date(YYYY.M.D)\n\n# Everything this module offers. The names beginning with an underscore are internal.\n__all__ = [\n    'DEFAULT_DDOF',\n    'classical_z_scores',\n    'max_attainable_z',\n]\n\nimport numpy as np\n\n# The divisor of the sum of squares is n - ddof. The sample standard deviation uses ddof = 1, and\n# the ceiling below is written for it; ddof = 0 is the population form and has its own ceiling.\nDEFAULT_DDOF = 1\n\n\ndef _as_ddof(ddof: int = DEFAULT_DDOF) -&gt; int:\n    &quot;&quot;&quot;Return the divisor correction, refusing a value the ceiling is not defined for.&quot;&quot;&quot;\n    if ddof not in (0, 1):\n        raise ValueError(f&quot;ddof must be 0 or 1, got {ddof}.&quot;)\n    return int(ddof)\n\n\ndef _as_sample(data: np.ndarray = None) -&gt; np.ndarray:\n    &quot;&quot;&quot;Return the sample as a 1-D float array, refusing input a z-score cannot be taken in.&quot;&quot;&quot;\n    values = np.asarray(data, dtype=float)\n    if values.ndim != 1:\n        raise ValueError(f&quot;data must be 1-D, got shape {values.shape}.&quot;)\n    if values.size &lt; 2:\n        raise ValueError(f&quot;a z-score needs at least 2 observations to have a scale, got {values.size}.&quot;)\n    if not np.all(np.isfinite(values)):\n        raise ValueError(f&quot;data carries {int((~np.isfinite(values)).sum())} non-finite values; &quot;\n                         f&quot;remove or impute them before scoring.&quot;)\n    return values\n\n\ndef classical_z_scores(data: np.ndarray = None, ddof: int = DEFAULT_DDOF) -&gt; np.ndarray:\n    &quot;&quot;&quot;Deviation of every observation from the mean, divided by the standard deviation.\n\n    Args:\n        data: the sample, shape (n,).\n        ddof: the divisor correction, 1 for the sample standard deviation and 0 for the\n            population form.\n\n    Returns:\n        The classical z-scores, shape (n,).\n    &quot;&quot;&quot;\n    values = _as_sample(data=data)\n    correction = _as_ddof(ddof=ddof)\n    scale = float(values.std(ddof=correction))\n    if scale == 0.0:\n        # Every observation equals the mean, so no observation is any distance from it at all.\n        # Returning zeros would report a clean sample where the score is simply not defined.\n        raise ValueError(f&quot;the standard deviation is 0 because all {values.size} observations are &quot;\n                         f&quot;{float(values[0])}; the classical score is undefined.&quot;)\n    return (values - values.mean()) \/ scale\n\n\ndef max_attainable_z(size: int = None, ddof: int = DEFAULT_DDOF) -&gt; float:\n    &quot;&quot;&quot;Largest absolute z-score a sample of the given size can produce, whatever its values.\n\n    The bound is arithmetic rather than a property of any data, and it is attained: one\n    observation set apart from size - 1 tied ones reaches it exactly.\n\n    Args:\n        size: the number of observations.\n        ddof: the divisor correction, as in classical_z_scores.\n\n    Returns:\n        The ceiling on the absolute z-score.\n    &quot;&quot;&quot;\n    correction = _as_ddof(ddof=ddof)\n    if not isinstance(size, (int, np.integer)):\n        raise ValueError(f&quot;size must be an integer, got {type(size).__name__}.&quot;)\n    if size &lt; 2:\n        raise ValueError(f&quot;size must be at least 2, got {size}.&quot;)\n    if correction == 1:\n        return float((size - 1) \/ np.sqrt(size))\n    return float(np.sqrt(size - 1))\"><pre><span class=\"pl-c\"># Math\/ZScore\/z_score_ceiling.py<\/span>\n<span class=\"pl-s1\">__author__<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">'yRocket'<\/span>\n<span class=\"pl-s1\">__version__<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s\">\"0.0.0.2026.8.18\"<\/span>  <span class=\"pl-c\"># Semantic Versioning: Major.Minor.Patch.Date(YYYY.M.D)<\/span>\n\n<span class=\"pl-c\"># Everything this module offers. The names beginning with an underscore are internal.<\/span>\n<span class=\"pl-s1\">__all__<\/span> <span class=\"pl-c1\">=<\/span> &#91;\n    <span class=\"pl-s\">'DEFAULT_DDOF'<\/span>,\n    <span class=\"pl-s\">'classical_z_scores'<\/span>,\n    <span class=\"pl-s\">'max_attainable_z'<\/span>,\n&#93;\n\n<span class=\"pl-k\">import<\/span> <span class=\"pl-s1\">numpy<\/span> <span class=\"pl-k\">as<\/span> <span class=\"pl-s1\">np<\/span>\n\n<span class=\"pl-c\"># The divisor of the sum of squares is n - ddof. The sample standard deviation uses ddof = 1, and<\/span>\n<span class=\"pl-c\"># the ceiling below is written for it; ddof = 0 is the population form and has its own ceiling.<\/span>\n<span class=\"pl-c1\">DEFAULT_DDOF<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">1<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">_as_ddof<\/span>(<span class=\"pl-s1\">ddof<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">DEFAULT_DDOF<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">int<\/span>:\n    <span class=\"pl-s\">\"\"\"Return the divisor correction, refusing a value the ceiling is not defined for.\"\"\"<\/span>\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">ddof<\/span> <span class=\"pl-c1\"><span class=\"pl-c1\">not<\/span> <span class=\"pl-c1\">in<\/span><\/span> (<span class=\"pl-c1\">0<\/span>, <span class=\"pl-c1\">1<\/span>):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"ddof must be 0 or 1, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">ddof<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">int<\/span>(<span class=\"pl-s1\">ddof<\/span>)\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">_as_sample<\/span>(<span class=\"pl-s1\">data<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Return the sample as a 1-D float array, refusing input a z-score cannot be taken in.\"\"\"<\/span>\n    <span class=\"pl-s1\">values<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">asarray<\/span>(<span class=\"pl-s1\">data<\/span>, <span class=\"pl-s1\">dtype<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">float<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">ndim<\/span> <span class=\"pl-c1\">!=<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"data must be 1-D, got shape <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">shape<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">size<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"a z-score needs at least 2 observations to have a scale, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">size<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">all<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">isfinite<\/span>(<span class=\"pl-s1\">values<\/span>)):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"data carries <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">int<\/span>((<span class=\"pl-c1\">~<\/span><span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">isfinite<\/span>(<span class=\"pl-s1\">values<\/span>)).<span class=\"pl-c1\">sum<\/span>())<span class=\"pl-kos\">}<\/span><\/span> non-finite values; \"<\/span>\n                         <span class=\"pl-s\">f\"remove or impute them before scoring.\"<\/span>)\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-s1\">values<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">classical_z_scores<\/span>(<span class=\"pl-s1\">data<\/span>: <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">ddof<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">DEFAULT_DDOF<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">ndarray<\/span>:\n    <span class=\"pl-s\">\"\"\"Deviation of every observation from the mean, divided by the standard deviation.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        data: the sample, shape (n,).<\/span>\n<span class=\"pl-s\">        ddof: the divisor correction, 1 for the sample standard deviation and 0 for the<\/span>\n<span class=\"pl-s\">            population form.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The classical z-scores, shape (n,).<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-s1\">values<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">_as_sample<\/span>(<span class=\"pl-s1\">data<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">data<\/span>)\n    <span class=\"pl-s1\">correction<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">_as_ddof<\/span>(<span class=\"pl-s1\">ddof<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">ddof<\/span>)\n    <span class=\"pl-s1\">scale<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">std<\/span>(<span class=\"pl-s1\">ddof<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">correction<\/span>))\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">scale<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">0.0<\/span>:\n        <span class=\"pl-c\"># Every observation equals the mean, so no observation is any distance from it at all.<\/span>\n        <span class=\"pl-c\"># Returning zeros would report a clean sample where the score is simply not defined.<\/span>\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"the standard deviation is 0 because all <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">size<\/span><span class=\"pl-kos\">}<\/span><\/span> observations are \"<\/span>\n                         <span class=\"pl-s\">f\"<span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">values<\/span>&#91;<span class=\"pl-c1\">0<\/span>&#93;)<span class=\"pl-kos\">}<\/span><\/span>; the classical score is undefined.\"<\/span>)\n    <span class=\"pl-k\">return<\/span> (<span class=\"pl-s1\">values<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-s1\">values<\/span>.<span class=\"pl-c1\">mean<\/span>()) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">scale<\/span>\n\n\n<span class=\"pl-k\">def<\/span> <span class=\"pl-en\">max_attainable_z<\/span>(<span class=\"pl-s1\">size<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">None<\/span>, <span class=\"pl-s1\">ddof<\/span>: <span class=\"pl-smi\">int<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-c1\">DEFAULT_DDOF<\/span>) <span class=\"pl-c1\">-&gt;<\/span> <span class=\"pl-smi\">float<\/span>:\n    <span class=\"pl-s\">\"\"\"Largest absolute z-score a sample of the given size can produce, whatever its values.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    The bound is arithmetic rather than a property of any data, and it is attained: one<\/span>\n<span class=\"pl-s\">    observation set apart from size - 1 tied ones reaches it exactly.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Args:<\/span>\n<span class=\"pl-s\">        size: the number of observations.<\/span>\n<span class=\"pl-s\">        ddof: the divisor correction, as in classical_z_scores.<\/span>\n<span class=\"pl-s\"><\/span>\n<span class=\"pl-s\">    Returns:<\/span>\n<span class=\"pl-s\">        The ceiling on the absolute z-score.<\/span>\n<span class=\"pl-s\">    \"\"\"<\/span>\n    <span class=\"pl-s1\">correction<\/span> <span class=\"pl-c1\">=<\/span> <span class=\"pl-en\">_as_ddof<\/span>(<span class=\"pl-s1\">ddof<\/span><span class=\"pl-c1\">=<\/span><span class=\"pl-s1\">ddof<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-c1\">not<\/span> <span class=\"pl-en\">isinstance<\/span>(<span class=\"pl-s1\">size<\/span>, (<span class=\"pl-s1\">int<\/span>, <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">integer<\/span>)):\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"size must be an integer, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-en\">type<\/span>(<span class=\"pl-s1\">size<\/span>).<span class=\"pl-c1\">__name__<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">size<\/span> <span class=\"pl-c1\">&lt;<\/span> <span class=\"pl-c1\">2<\/span>:\n        <span class=\"pl-k\">raise<\/span> <span class=\"pl-en\">ValueError<\/span>(<span class=\"pl-s\">f\"size must be at least 2, got <span class=\"pl-s1\"><span class=\"pl-kos\">{<\/span><span class=\"pl-s1\">size<\/span><span class=\"pl-kos\">}<\/span><\/span>.\"<\/span>)\n    <span class=\"pl-k\">if<\/span> <span class=\"pl-s1\">correction<\/span> <span class=\"pl-c1\">==<\/span> <span class=\"pl-c1\">1<\/span>:\n        <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">float<\/span>((<span class=\"pl-s1\">size<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>) <span class=\"pl-c1\">\/<\/span> <span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">sqrt<\/span>(<span class=\"pl-s1\">size<\/span>))\n    <span class=\"pl-k\">return<\/span> <span class=\"pl-en\">float<\/span>(<span class=\"pl-s1\">np<\/span>.<span class=\"pl-c1\">sqrt<\/span>(<span class=\"pl-s1\">size<\/span> <span class=\"pl-c1\">-<\/span> <span class=\"pl-c1\">1<\/span>))<\/pre><\/div>\n<div class=\"markdown-heading\" dir=\"auto\"><h2 class=\"heading-element\" dir=\"auto\">Appendix C. Worked Example<\/h2><a id=\"user-content-appendix-c-worked-example\" class=\"anchor\" aria-label=\"Permalink: Appendix C. Worked Example\" href=\"#appendix-c-worked-example\"><svg data-component=\"Octicon\" class=\"octicon octicon-link\" viewBox=\"0 0 16 16\" version=\"1.1\" width=\"16\" height=\"16\" aria-hidden=\"true\"><path d=\"m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z\"><\/path><\/svg><\/a><\/div>\n<p dir=\"auto\">Every number in this appendix is produced by <code>z_score_worked_example.py<\/code>, invoked as\n<code>python3 z_score_worked_example.py --threshold 3.5<\/code>. The script reads the sample from\n<code>EDA\/Outlier\/data\/1d_esc_current.csv<\/code> and writes the points behind the figure beside the figure\nas CSV.<\/p>\n<p dir=\"auto\">The sample is fifteen current measurements. Fourteen of them sit near 0.02 and one is 0.6532,\nwhich is the shape section 2.3 describes: one observation set apart from a tight group. It\ntherefore sits close to the configuration that attains the ceiling, which here is nothing\ndistant: it stands a few thousandths above the largest score in the sample.<\/p>\n<p dir=\"auto\"><strong>Table 2. The sample against its ceiling, and the ceiling one observation lower<\/strong><\/p>\n<markdown-accessiblity-table><table>\n<thead>\n<tr>\n<th>Quantity<\/th>\n<th>Value<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Observations<\/td>\n<td>15<\/td>\n<\/tr>\n<tr>\n<td>Mean<\/td>\n<td>0.062913<\/td>\n<\/tr>\n<tr>\n<td>Standard deviation<\/td>\n<td>0.163469<\/td>\n<\/tr>\n<tr>\n<td>Largest absolute z<\/td>\n<td>3.611012<\/td>\n<\/tr>\n<tr>\n<td>Ceiling at n = 15<\/td>\n<td>3.614784<\/td>\n<\/tr>\n<tr>\n<td>Share of the ceiling reached<\/td>\n<td>99.90%<\/td>\n<\/tr>\n<tr>\n<td>Ceiling at n = 14<\/td>\n<td>3.474396<\/td>\n<\/tr>\n<\/tbody>\n<\/table><\/markdown-accessiblity-table>\n<p dir=\"auto\">A rule at 3.5 flags that largest score, but it clears the cut-off by 0.111 while sitting only\n0.004 below the ceiling. The verdict rests on the sample size almost as much as on the\nmeasurement.<\/p>\n<p dir=\"auto\">Removing one observation makes that plain. At fourteen the ceiling is 3.474396, below the\ncut-off, so the same measurement in a sample one smaller could not be flagged at 3.5 at all.<\/p>\n<p dir=\"auto\"><a target=\"_blank\" rel=\"noopener noreferrer\" href=\"https:\/\/github.com\/ykim2718\/Math\/blob\/main\/ZScore\/z-score-ceiling_fig\/z_score_ceiling.png\"><img src=\"https:\/\/ykim.synology.me\/wordpress\/wp-json\/gh-readme\/v1\/asset?user=ykim2718&#038;repo=Math&#038;branch=main&#038;path=ZScore\/z-score-ceiling_fig\/z_score_ceiling.png&#038;sig=44b951d5335d1eef643fa55ac4e05cac1be9699c0ae5490a4e18315a88c11370\" alt=\"Fig 1\" style=\"max-width: 100%;\"><\/a><\/p>\n<p dir=\"auto\"><strong>Fig 1. The ceiling against sample size, and the scores this sample reaches under it<\/strong><\/p>\n<p dir=\"auto\">Panel (a) draws <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$(n-1)\/\\sqrt{n}$<\/math-renderer> against <math-renderer class=\"js-inline-math\" style=\"display: inline-block\" data-run-id=\"12aecc4bec460c7c19b88b340fb7b51a\">$n$<\/math-renderer> and marks where it crosses 3.5, which is the first\nsample size at which a rule at that cut-off can fire. Panel (b) draws the fifteen absolute scores\nagainst the ceiling for a sample of fifteen: fourteen of them lie below 0.31, and the flagged one\nsits just under the line it cannot cross.<\/p>\n<\/article><\/div><\/div><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n<div style='text-align:center' class='yasr-auto-insert-overall'><\/div><div style='text-align:center' class='yasr-auto-insert-visitor'><\/div>","protected":false},"excerpt":{"rendered":"<p>No absolute z-score in a sample of n can exceed (n\u22121)\/\u221an, because the observation under test sits inside its own denominator. At a cut-off of 3.5 a sample of fourteen can never flag anything, whatever the data are. Covers Shiffler&#8217;s bound, its derivation, when equality holds, and the ddof trap.<\/p>\n","protected":false},"author":4,"featured_media":6800,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"_kadence_starter_templates_imported_post":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","yasr_overall_rating":0,"yasr_post_is_review":"","yasr_auto_insert_disabled":"","yasr_review_type":"","fifu_image_url":"","fifu_image_alt":"","iawp_total_views":14,"footnotes":""},"categories":[384,56],"tags":[386],"class_list":["post-6797","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-eda-slug","category-data-science-slug","tag-github-hosted"],"yasr_visitor_votes":{"stars_attributes":{"read_only":false,"span_bottom":false},"number_of_votes":1,"sum_votes":4},"jetpack_featured_media_url":"https:\/\/ykim.synology.me\/wordpress\/wp-content\/uploads\/2026\/08\/heb-plus-storefront-dusk.jpg","_links":{"self":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6797","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/comments?post=6797"}],"version-history":[{"count":6,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6797\/revisions"}],"predecessor-version":[{"id":7458,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/posts\/6797\/revisions\/7458"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media\/6800"}],"wp:attachment":[{"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/media?parent=6797"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/categories?post=6797"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ykim.synology.me\/wordpress\/wp-json\/wp\/v2\/tags?post=6797"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}