Main Content

erf

構文

説明

erf(x) は、x の各要素について評価した誤差関数を返します。

すべて折りたたむ

値の誤差関数を求めます。

erf(0.76)
ans = 0.7175

ベクトルの要素の誤差関数を求めます。

V = [-0.5 0 1 0.72];
erf(V)
ans = 1×4

   -0.5205         0    0.8427    0.6914

行列の要素の誤差関数を求めます。

M = [0.29 -0.11; 3.1 -2.9];
erf(M)
ans = 2×2

    0.3183   -0.1236
    1.0000   -1.0000

標準偏差 σ、平均値 μ をもつ正規 (ガウス) 分布の累積分布関数 (CDF) は次のようになります。

ϕ(x)=12(1+erf(x-μσ2)).

erfc を使用して式を書き直せば、演算精度を上げることができます。詳細については、ヒントを参照してください。

μ=0 および σ=1 の正規分布の CDF をプロットします。

x = -3:0.1:3;
y = (1/2)*(1+erf(x/sqrt(2)));
plot(x,y)
grid on
title('CDF of normal distribution with \mu = 0 and \sigma = 1')
xlabel('x')
ylabel('CDF')

Figure contains an axes object. The axes object with title CDF of normal distribution with mu blank = blank 0 blank and blank sigma blank = blank 1, xlabel x, ylabel CDF contains an object of type line.

u(x,t) が位置 x、時刻 t の温度を表す場合、熱方程式は次のようになります。

ut=c2ux2,

ここで、c は定数です。

物質の熱伝導係数が k であり、初期条件が x>bu(x,0)=a、それ以外では u(x,0)=0 である場合、熱方程式の解は次のようになります。

u(x,t)=a2(erf(x-b4kt)).

k = 2a = 5、かつ b = 1 の場合について、時刻 t = 0.15100 における熱方程式の解をプロットします。

x = -4:0.01:6;
t = [0.1 5 100];
a = 5;
k = 2;
b = 1;
figure(1)
hold on
for i = 1:3
    u(i,:) = (a/2)*(erf((x-b)/sqrt(4*k*t(i))));
    plot(x,u(i,:))
end
grid on
xlabel('x')
ylabel('Temperature')
legend('t = 0.1','t = 5','t = 100','Location','best')
title('Temperatures across material at t = 0.1, t = 5, and t = 100')

Figure contains an axes object. The axes object with title Temperatures across material at t = 0.1, t = 5, and t = 100, xlabel x, ylabel Temperature contains 3 objects of type line. These objects represent t = 0.1, t = 5, t = 100.

入力引数

すべて折りたたむ

入力。実数、あるいは実数のベクトル、行列または多次元配列として指定します。x をスパースにすることはできません。

データ型: single | double

詳細

すべて折りたたむ

誤差関数

x の誤差関数 erf は次の式で表されます。

erf(x)=2π0xet2dt.

ヒント

  • 関数 normcdf (Statistics and Machine Learning Toolbox) を使用しても、標準正規確率分布を得ることができます。誤差関数 erfnormcdf の関係は次のとおりです。

    normcdf(x)=12(1erf(x2)).

  • 1 - erf(x) の形式の式では、代わりに相補誤差関数 erfc を使用します。この置き換えでは精度が維持されます。erf(x)1 に近い場合、1 - erf(x) が小さい数値になり 0 に丸められることがあります。代わりに、1 - erf(x)erfc(x) に置き換えます。

拡張機能

バージョン履歴

R2006a より前に導入

参考

| | |