什麼是誤差函數表計算器?
這個工具會針對一連串 x 值,建立高斯誤差函數 erf(x) 與互補誤差函數 erfc(x) 的數值表。誤差函數廣泛出現在機率、統計、熱傳導與擴散問題中。由於它是純粹的數學特殊函數,因此在世界各地的計算結果完全一致,不受任何國家或地區規則影響。
如何使用
請輸入三個數字:x 的初始值(第一列)、每一列遞增加到 x 上的增量,以及疊代次數(列數)。計算器會依公式 \(x = \text{起始值} + i \times \text{增量}\)(\(i = 0, 1, \dots, \text{列數}-1\))產生各列數值,並列出每一列的 erf(x) 與 erfc(x)。增量可以是負數(產生遞減的表格),也可以是零(所有列數值相同)。
計算公式
$$\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^{2}}\,dt, \qquad \operatorname{erfc}(x) = 1 - \operatorname{erf}(x)$$本工具採用 Abramowitz & Stegun 7.1.26 的有理函數近似式計算(最大誤差約為 \(1.5 \times 10^{-7}\)),並利用奇對稱性質 \(\operatorname{erf}(-x) = -\operatorname{erf}(x)\) 來處理負值參數。
實際範例
當初始值為 0、增量為 0.5、列數為 5 時,會得到 \(x = 0, 0.5, 1.0, 1.5, 2.0\)。其中 \(\operatorname{erf}(1.0) \approx 0.8427008\),\(\operatorname{erfc}(1.0) \approx 0.1572992\),兩者相加 \(\operatorname{erf}(1.0) + \operatorname{erfc}(1.0) = 1\),正好驗證了這項恆等式。
常用 erf(x) 與 erfc(x) 參考值
高斯誤差函數為 \(\operatorname{erf}(x) = \frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2}\,dt\),互補誤差函數為 \(\operatorname{erfc}(x) = 1 - \operatorname{erf}(x)\)。下表列出廣泛使用的數值,四捨五入至小數點後 7 位。你可以用起始值 = 0、增量 = 0.5 及 7 列來重現此表。
| x | erf(x) | erfc(x) |
|---|---|---|
| 0 | 0.0000000 | 1.0000000 |
| 0.5 | 0.5204999 | 0.4795001 |
| 1 | 0.8427008 | 0.1572992 |
| 1.5 | 0.9661051 | 0.0338949 |
| 2 | 0.9953223 | 0.0046777 |
| 2.5 | 0.9995930 | 0.0004070 |
| 3 | 0.9999779 | 0.0000221 |
對稱性:erf 是奇函數,因此 \(\operatorname{erf}(-x) = -\operatorname{erf}(x)\),進而 \(\operatorname{erfc}(-x) = 1 + \operatorname{erf}(x) = 2 - \operatorname{erfc}(x)\)。當 x 增大時,erf(x) 趨近於 1,erfc(x) 趨近於 0。
解讀 erf 與 erfc 數值
與常態分布的關係。 標準常態累積分布函數為
$$\Phi(z) = \tfrac{1}{2}\left[1 + \operatorname{erf}\left(\frac{z}{\sqrt{2}}\right)\right]$$
對於平均數為 μ、標準差為 σ 的常態隨機變數 X,erf(x) 是其值落在距平均數 x·σ·√2 範圍內的機率:
$$P\left(|X-\mu| \le x\,\sigma\sqrt{2}\right) = \operatorname{erf}(x)$$
範例:
- \(\operatorname{erf}(1/\sqrt{2}) \approx 0.6827\):約 68.27% 的數值落在 ±1σ 之內。
- \(\operatorname{erf}(2/\sqrt{2}) \approx 0.9545\):約 95.45% 的數值落在 ±2σ 之內。
- \(\operatorname{erf}(3/\sqrt{2}) \approx 0.9973\):約 99.73% 的數值落在 ±3σ 之內。
erfc 作為尾部機率。 erfc(x) 是落在該中央區間之外的機率,即兩側尾部合計。以 Q(z) = 1 − Φ(z) 作為上尾機率,\(\operatorname{erfc}(x) = 2\,Q(x\sqrt{2})\)。例如 erfc(1/√2) ≈ 0.3173,即超出 ±1σ 的雙側機率。
精確度說明。 許多快速實作使用有理近似(例如 Abramowitz and Stegun 公式),其最大絕對誤差約為 1.5×10⁻⁷。對 erf(x) 本身而言這已足夠,但 erfc(x) = 1 − erf(x) 在 x 較大時會變得非常小(erfc(3) ≈ 2.2×10⁻⁵,erfc(5) ≈ 1.5×10⁻¹²)。因此 10⁻⁷ 的絕對誤差會使遠尾值的大部分或全部有效數字失去意義。對於大 x 時非常小的 erfc 數值,應視為近似值;若需要精確的極端尾部機率,請使用專門的高精度 erfc 程式。
常見問題
erf 的取值範圍是多少?\(\operatorname{erf}(x)\) 介於 \((-1, 1)\) 之間;\(\operatorname{erf}(0) = 0\)、\(\operatorname{erf}(+\infty) = 1\)、\(\operatorname{erf}(-\infty) = -1\)。
那 erfc 呢?\(\operatorname{erfc}(x)\) 介於 \((0, 2)\) 之間:\(\operatorname{erfc}(0) = 1\)、\(\operatorname{erfc}(+\infty) = 0\)、\(\operatorname{erfc}(-\infty) = 2\)。
最多可以產生多少列?列數必須是正整數;為了讓輸出結果便於閱讀,表格上限為 2000 列。