名前空間
変種
操作

erf, erff, erfl

提供: cppreference.com
< c‎ | numeric‎ | math
 
 
 
一般的な数学関数
関数
基本操作
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
指数関数
(C99)
(C99)
(C99)
(C99)
冪関数
(C99)
(C99)
三角関数と双曲線関数
誤差関数とガンマ関数
erf
(C99)
(C99)
(C99)
(C99)
最も近い整数
(C99)(C99)(C99)
(C99)
(C99)
(C99)(C99)(C99)
浮動小数点操作関数
(C99)(C99)
(C99)
(C99)
分類
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)
マクロ定数
 
ヘッダ <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) arg誤差関数を計算します。
4) 型総称マクロ。 arglong double 型の場合は erfl が呼ばれます。 そうでなく、 arg が整数型または double 型の場合は erf が呼ばれます。 そうでなければ erff が呼ばれます。

[編集] 引数

arg - 浮動小数点値

[編集] 戻り値

エラーが発生しなければ、 arg の誤差関数の値、すなわち \(\frac{2}{\sqrt{\pi} }\int_{0}^{arg}{e^{-{t^2} }\mathsf{d}t}\)
2
π
arg
0
e-t2
dt
が返されます。 アンダーフローによる値域エラーが発生した場合、 (丸めた後の) 正しい結果、すなわち \(\frac{2\cdot arg}{\sqrt{\pi} }\)
2*arg
π
が返されます。

[編集] エラー処理

math_errhandling で規定されている通りにエラーが報告されます。

処理系が IEEE 浮動小数点算術 (IEC 60559) をサポートしている場合、

  • 引数が ±0 であれば、 ±0 が返されます。
  • 引数が ±∞ であれば、 ±1 が返されます。
  • 引数が NaN であれば、 NaN が返されます。

[編集] ノート

|arg| < DBL_MIN *(sqrt (π)/2) の場合、アンダーフローが保証されます。

\(\operatorname{erf}(\frac{x}{\sigma \sqrt{2} })\)erf(
x
σ2
)
は、誤差が標準偏差 \(\sigma\)σ の正規分布である測定値の、平均値からの距離が \(x\)x より小さい確率です。

[編集]

Run this code
#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.000000
erf(Inf) = 1.000000

[編集] 参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.12.8.1 The erf functions (p: 249)
  • 7.25 Type-generic math <tgmath.h> (p: 373-375)
  • F.10.5.1 The erf functions (p: 525)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.12.8.1 The erf functions (p: 230)
  • 7.22 Type-generic math <tgmath.h> (p: 335-337)
  • F.9.5.1 The erf functions (p: 462)

[編集] 関連項目

(C99)(C99)(C99)
相補誤差関数を計算します
(関数) [edit]

[編集] 外部リンク

Weisstein, Eric W. "Erf." From MathWorld--A Wolfram Web Resource.
https://ja.cppreference.com/mwiki/index.php?title=c/numeric/math/erf&oldid=48022」から取得

AltStyle によって変換されたページ (->オリジナル) /