Numpy Complementary Error Function
Contents |
2/sqrt(pi)*integral(exp(-t**2), t=0..z). Parameters:x module 'scipy' has no attribute 'special' : ndarray Input array. Returns:res : ndarray The values of error function wiki the error function at the given points x. See also erfc, erfinv, erfcinv Notes The cumulative of the unit normal distribution
Python Cumulative Distribution Function
is given by Phi(z) = 1/2[1 + erf(z/sqrt(2))]. References [R200]http://en.wikipedia.org/wiki/Error_function [R201]Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972. http://www.math.sfu.ca/~cbm/aands/page_297.htm [R202]Steven G. Johnson, Faddeeva W function implementation. http://ab-initio.mit.edu/Faddeeva Previous topic scipy.special.multigammaln Next topic scipy.special.erfc © Copyright 2008-2009, The Scipy community. Last updated on May 11, 2014. Created using Sphinx 1.2.2.
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business
Python Error Handling Best Practices
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs erf calculator Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just erfc like you, helping each other. Join them; it only takes a minute: Sign up Is there an easily available implementation of erf() for Python? up vote 36 down vote favorite 7 I can implement the error function, http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.special.erf.html erf, myself, but I'd prefer not to. Is there a python package with no external dependencies that contains an implementation of this function? I have found http://pylab.sourceforge.net/packages/included_functions.html>this but this seems to be part of some much larger package (and it's not even clear which one!). I'm sorry if this is a naive question - I'm totally new to Python. python math share|improve this question asked Jan 19 '09 at 12:10 rog 2,21211721 add a comment| http://stackoverflow.com/questions/457408/is-there-an-easily-available-implementation-of-erf-for-python 7 Answers 7 active oldest votes up vote 44 down vote Since v.2.7. the standard math module contains erf function. This should be the easiest way. http://docs.python.org/2/library/math.html#math.erf share|improve this answer edited Nov 19 '13 at 14:28 Colonel Panic 53.2k33221278 answered Jul 12 '11 at 9:31 bezalel 59146 1 +1: simplest answer. –Neil G Dec 21 '11 at 4:42 Wow! Never noticed that! –smci May 20 '13 at 23:30 Is there a Python module that provides erf⁻¹(x) ? –Lori Feb 1 '15 at 22:49 add a comment| up vote 39 down vote I recommend SciPy for numerical functions in Python, but if you want something with no dependencies, here is a function with an error error is less than 1.5 * 10-7 for all inputs. def erf(x): # save the sign of x sign = 1 if x >= 0 else -1 x = abs(x) # constants a1 = 0.254829592 a2 = -0.284496736 a3 = 1.421413741 a4 = -1.453152027 a5 = 1.061405429 p = 0.3275911 # A&S formula 7.1.26 t = 1.0/(1.0 + p*x) y = 1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*math.exp(-x*x) return sign*y # erf(-x) = -erf(x) The algorithm comes from Handbook of Mathematical Functions, formula 7.1.26. share|improve this answer edited Dec 21 '11 at 4:41 Neil G 11.1k1982168 answered Jan 19
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack http://stackoverflow.com/questions/31266249/command-for-inverse-erf-function-in-python Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up command for inverse ERF function in python [closed] up vote 7 down vote favorite What error function is the command to calculate Inverse Error function (erf) of a function in a python and which module is needed to import? python python-2.7 python-3.x numpy share|improve this question asked Jul 7 '15 at 10:37 Naitik Mathur 442 closed as unclear what you're asking by jonrsharpe, ekad, cel, HaveNoDisplayName, Soner Gönül Jul 7 '15 at 14:50 Please clarify your specific problem or add additional details to highlight exactly what you need. numpy complementary error As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question. add a comment| 2 Answers 2 active oldest votes up vote 10 down vote For the inverse error function, scipy.special has erfinv: http://docs.scipy.org/doc/scipy/reference/generated/scipy.special.erfinv.html#scipy.special.erfinv In [4]: from scipy.special import erfinv In [5]: erfinv(1) Out[5]: inf In [6]: erfinv(0.4) Out[6]: 0.37080715859355784 share|improve this answer answered Jul 7 '15 at 10:41 xnx 11.1k31541 add a comment| up vote 0 down vote I suggest to use scipy, a library that uses numpy. the module you need to import to use is erfinv: from scipy.special import erfinv Scipy is a key player for numerical software in Python. But it might be a little challenging getting started with it. share|improve this answer edited Jul 7 '15 at 10:46 answered Jul 7 '15 at 10:40 DJanssens 1,8143826 add a comment| Not the answer you're looking for? Browse other questions tagged python python-2.7 python-3.x numpy or ask your own question. asked 1 year ago viewed 1657 times active 1 year ago Related 1146How can I represent an 'Enum' in Python?2316Calling an external command in Python5532What does the “yield&rd