Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

No Inverse Error function?

William_S_1
Beginner
4,508 Views

The Fortran Math library has ERF for the error function, but I have not been able to find the Inverse.

Its a statistical function based upon the Gaussian Normal distribution.

 

Strangely enough, it does exist for VECTOR ELEMENTS, but I don't see why they would not

include it for regular usage. Every other math library on other processors has this function.

If it is in the library, searching for it produces no results.

How do we use vector elements - what are they referring to?

 

(in case I get desperate)

'

0 Kudos
11 Replies
pbkenned1
Employee
4,508 Views

The IMSL package add-on has ERFI, but I don't think it is a part of standard Intel Fortran.  Can you expand on 'it does exist for VECTOR ELEMENTS'?

Patrick

0 Kudos
Steven_L_Intel1
Employee
4,508 Views
What you've found is entries for erfinv in Intel MKL. Fortran does not define the erfinv intrinsic. You can use this from MKL but it is defined on arrays only. You could pass a single-element array if you wanted. Ask over in the MKL forum if you need more help.
0 Kudos
FortranFan
Honored Contributor III
4,508 Views

As explained by John Reid in his 2014 report, "The New Features of Fortran 2008", the following 3 new intrinsic functions have been added to the Fortran 2008 standard and I think these are available in the latest Intel Fortran compiler version:

ErrorFunctions.png

What exactly is the inverse error function?  Is it the same as the complementary error function (erfc(x)) explained above?

0 Kudos
mecej4
Honored Contributor III
4,508 Views

FortranFan: if y = erf(x), x = inverf(y); if y = erfc(x), x = inverfc(y), as is usual in mathematics

William S.: there is nothing that keeps you from calling the VML/VSL functions with a vector argument containing a single component. For example:

program xinverf
implicit none
include 'mkl_vml.f90'
integer,parameter :: n=1
integer*8 mode
real a(1),v(1)

a(1) = 0.4
call vserfcinv(n, a, v)
write(*,*)v(1)
end program xinverf

With this program we get

S:\MKL> ifort /Qmkl xerfinv.f90

S:\MKL> xerfinv
  0.5951161

 

0 Kudos
FortranFan
Honored Contributor III
4,508 Views

mecej4 wrote:

.. if y = erf(x), x = inverf(y); if y = erfc(x), x = inverfc(y), as is usual in mathematics

..

Thanks mecej4.

Then another question - perhaps for Steve or other folks more familiar with the Fortran standards development and/or those who are more mathematically inclined:

If the Fortran standard now includes the error function (erf(x)), any idea why the inverse isn't?

Is it mathematically too complicated (it's been a while, too lazy to run now to our library to consult the math handbooks), or the methods approximate or involve more intricate details, or constrained by some technical artifact (e.g., valid only in certain domains), or some proprietary issues with the solvers that the standard body would decide to punt on this?

 

0 Kudos
Steven_L_Intel1
Employee
4,508 Views
erfinv isn't really all that popular in language libraries. It's not in typical C libraries. For Fortran 2008, the standard added a bunch of mathematical intrinsics popular for C, but erfinv wasn't among them. I searched the J3 archives and don't see even a suggestion that it be included. I see that C++ has added erfinv, but Fortran doesn't tend to follow C++.
0 Kudos
William_S_1
Beginner
4,508 Views

Its pretty awkward to have to make the Inputs vectors.

I don't see any useful purpose in that, unless it has to do with

optimization of the results. After all, one can get the same answers by using a DO LOOP.

 

And why they did that for the Error function and its complement, and not for their inverses,

which are used just as often, is a mystery. As any statistician will tell you - just ask ! ! !

 

for example you would use the inverse when you know the probability of an outcome,

and you want to know its Z value (no of standard deviations away from the mean) corresponding

to that. It's used all the time.

That would be like having a SINE function but no ARCSINE, or a TAN function, but no ARC Tangent.

0 Kudos
WSinc
New Contributor I
4,508 Views

That thing that mecej4 sent me doesn't work either.

says its can't find the function. None of them in fact.

I did put in the INCLUDE statement they recommended.

 

so those statitistical functions, if they are in the MKL libary,

are unusable.

0 Kudos
TimP
Honored Contributor III
4,508 Views

I suppose those who say calling MKL is too difficult aren't likely to use it, but C source code (with poor documentation) for erfinv (apparently just a bit more than single precision) is presented at

http://libit.sourceforge.net/math_8c-source.html

which could be trivially translated to Fortran or called via bind(c).

I'm struggling to understand whether the VS2012/2013 implementation is for Nvidia accelerator only.

An article on how it was implemented for Nvidia:

http://people.maths.ox.ac.uk/gilesm/files/gems_erfinv.pdf

0 Kudos
William_S_1
Beginner
4,508 Views

I did "kluge" up an inverse error function, for those that are interested.

Any statistical application would have to have it...........

 

It uses the existing ERF in the Fortran library and a set of linear approximations

to iterate on the answer. Just like you could use the Newton_Raphson technique to

get an ARC Tangent if you didn't already have one.

 

The C++ library routine it appears uses a set of polynomials, so that might be faster.

But you may not get the full REAL*8 accuracy. It does have D.P variables though.

0 Kudos
Steven_L_Intel1
Employee
4,508 Views

You need to select the "Use Intel Math Kernel Library" option under Fortran > Libraries.

0 Kudos
Reply