Faster / more precise logarithm of complimentary error function?
30 ビュー (過去 30 日間)
古いコメントを表示
If there is a way to calculate the logarithm of complimentary error function with better numerical precision (and preferably also faster) than doing it in the straightforward manner, e.g.
log(erfc(-5:5))
ans =
0.6931 0.6931 0.6931 0.6908 0.6112 0 -1.8496 -5.3649 -10.7204 -17.9878 -27.2009
As far as I know, many of numerical approximations involve product that includes exponential in some form e.g. see Wikipedia, so it feels that some potential gain could be achieved through it.
0 件のコメント
回答 (5 件)
Walter Roberson
2017 年 9 月 23 日
編集済み: Walter Roberson
2017 年 9 月 23 日
No, the algorithms involve the sum of exponentiation times another factor, not products that you could potentially turn into sums.
erfc() is a built-in in MATLAB. It is going to call into some built-in library function written in C or C++ . To have any chance of matching the speed, your replacement would also have to be in C or C++.
John D'Errico
2017 年 9 月 23 日
If you want speed, no, you are not going to beat log(erfc(x)), at least not without writing custom code, preferably in some compiled language.
If you want higher accuracy for large positive x, then yes you could get more accuracy in the upper tail. It won't be incredibly fast though. I'd probably start with the simple asymptotic expansion given on the wikipedia page.
Be careful though, as the classic asymptotic expansion actually diverges if you take too many terms. But for moderately small x, you would need perhaps more terms to get an adequate number of digits. It depends on how many digits of accuracy you need/want. The point is, you need to do some careful work to choose an expansion that will be fast AND highly accurate. The problem will be for intermediate values of x, perhaps on the order of 1 to 2.
0 件のコメント
Shep Bryan
2020 年 3 月 31 日
If you are mainly worried about underlow, this is a handy function that avoids numerical issues:
function out = logerfc(X)
out = log(erfcx(X)) - X.^2;
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interpolation of 2-D Selections in 3-D Grids についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!