使用Enthought
我需要计算一个叫做互补误差函数的反函数(erfc^(1)),这是我在解决一个问题时需要的。
我在找Python的工具来帮忙,很多讨论都提到Enthought这个软件有很多数学工具,所以我下载并安装到了我的本地用户账户里。但我不太确定该怎么使用它。
有没有什么建议?
2 个回答
1
这里有一个简单的例子,展示了在Enthought Python Distribution(EPD)中如何进行计算,使用的是互补误差函数的反函数(erfcinv
)。这个函数包含在EPD自带的SciPy包里:
C:\>c:\Python25\python
EPD Py25 (4.1.30101) -- http://www.enthought.com/epd
Python 2.5.2 |EPD Py25 4.1.30101| (r252:60911, Dec 19 2008, 13:49:12) [MSC v.131
0 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from scipy.special import erfcinv
>>> erfcinv(0.)
1.271161006153646e+308
>>> erfcinv(1.)
0.0
>>> erfcinv(2.)
-1.271161006153646e+308
>>> exit()
C:\>
8
SciPy是一个包含在Enthought Python发行版中的库,它里面有一个特殊函数。
In [1]: from scipy.special import erfcinv
In [2]: from numpy import linspace
In [3]: x = linspace(0, 1, 10)
In [4]: y = erfcinv(x)
In [5]: y
Out[5]:
array([ 1.27116101e+308, 1.12657583e+000, 8.63123068e-001,
6.84070350e-001, 5.40731396e-001, 4.16808192e-001,
3.04570194e-001, 1.99556951e-001, 9.87900997e-002,
0.00000000e+000])