?
This document uses PHP Chinese website manual Release
在頭文件<math.h>中定義 | ||
---|---|---|
float erff(float arg); | (1) | (自C99以來) |
double erf(double arg); | (2) | (自C99以來) |
long double erfl(long double arg); | (3) | (自C99以來) |
在頭文件<tgmath.h>中定義 | ||
#define erf(arg) | (4) | (自C99以來) |
1-3)計(jì)算arg的誤差函數(shù)。
4)類型 - 通用宏:如果arg的類型是long double,則調(diào)用erfl。 否則,如果arg具有整數(shù)類型或類型double,則調(diào)用erf。 否則,erff被調(diào)用。
arg | - | floating point value |
---|
如果沒有錯(cuò)誤發(fā)生,arg的錯(cuò)誤函數(shù)的值為:
| 2 |
|:----|
| √π |
∫arg
0e-t2
d t被返回。如果由于下溢而發(fā)生范圍錯(cuò)誤,則正確的結(jié)果(四舍五入后)為:
| 2*arg |
|:----|
| √π |
,返回。
按照math_errhandling中的指定報(bào)告錯(cuò)誤。
如果實(shí)現(xiàn)支持IEEE浮點(diǎn)運(yùn)算(IEC 60559),
如果參數(shù)為±0,則返回±0
如果參數(shù)為±∞,則返回±1
如果參數(shù)是NaN,則返回NaN
如果| arg |,則保證下溢 <DBL_MIN *(sqrt(π)/ 2)。erf(
| x |
|:----|
| σ√2 |
)是誤差符合標(biāo)準(zhǔn)偏差σ的正態(tài)分布的測量值小于平均值的x的概率。
#include <stdio.h>#include <math.h>double phi(double x1, double x2){ return (erf(x2/sqrt(2)) - erf(x1/sqrt(2)))/2;}int main(void){ puts("normal variate probabilities:"); for(int n=-4; n<4; ++n) printf("[%2d:%2d]: %5.2f%%\n", n, n+1, 100*phi(n, n+1)); puts("special values:"); printf("erf(-0) = %f\n", erf(-0.0)); printf("erf(Inf) = %f\n", erf(INFINITY));}
輸出:
normal variate probabilities:[-4:-3]: 0.13%[-3:-2]: 2.14%[-2:-1]: 13.59%[-1: 0]: 34.13%[ 0: 1]: 34.13%[ 1: 2]: 13.59%[ 2: 3]: 2.14%[ 3: 4]: 0.13%special values:erf(-0) = -0.000000erf(Inf) = 1.000000
C11標(biāo)準(zhǔn)(ISO / IEC 9899:2011):
7.12.8.1 erf函數(shù)(p:249)
7.25類型通用數(shù)學(xué)<tgmath.h>(p:373-375)
F.10.5.1 erf函數(shù)(p:525)
C99標(biāo)準(zhǔn)(ISO / IEC 9899:1999):
7.12.8.1 erf函數(shù)(p:230)
7.22類型通用數(shù)學(xué)<tgmath.h>(p:335-337)
F.9.5.1 erf函數(shù)(p:462)
erfcerfcferfcl (C99)(C99)(C99) | 計(jì)算互補(bǔ)誤差函數(shù)(函數(shù)) |
---|
| erf 的C ++文檔|