Skip to content

Commit

Permalink
add log1mexp.m
Browse files Browse the repository at this point in the history
  • Loading branch information
sth4nth committed Aug 26, 2017
1 parent e1c19a5 commit 272477e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/log1mexp.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function y = log1mexp(x)
% Accurately compute y = log(1-exp(-x))
% reference: Accurately Computing log(1-exp(-|a|)) Martin Machler
y = x;
i = x > log(2);
y(i) = log1p(-exp(-x(i)));
y(~i) = log(-expm1(-x(~i)));

0 comments on commit 272477e

Please sign in to comment.