%% Avoid Roundoff Errors Using Inverse Complementary Error Function
% You can use the inverse complementary error function erfcinv in place of erfinv(1-x) to avoid roundoff errors when x is close to 0.
% Show how to avoid roundoff by calculating erfinv(1-x) using erfcinv(x) for x = 1e-100. The original calculation returns Inf while erfcinv(x) returns the correct result.

x = 1e-100;
erfinv(1-x)
erfcinv(x)

% Copyright 2015 The MathWorks, Inc.