gpt4 book ai didi

python - numpy 1.6.1 未找到多项式对象的求积属性

转载 作者:行者123 更新时间:2023-11-30 23:41:39 26 4
gpt4 key购买 nike

我正在使用 python 2.7.3 和 numpy 1.6.1。我正在尝试获取勒让德多项式和厄米多项式的高斯求积点。根据numpy documentation ,我应该能够通过键入

来访问该属性

numpy.polynomial.legendre.leggauss(1)

但是每当我这样做时(即使对于 Hermite 或 Hermite_e)我都会收到错误

AttributeError: 'module' object has no attribute 'leggauss'

这是怎么回事?这么重要的属性怎么能少呢?我使用的是 Mac OS X 10.7.4。下面是我在 python 中输入的确切代码:

Python 2.7.3 (default, Jul 12 2012, 11:58:31) 
[GCC 4.2.1 Compatible Apple Clang 3.1 (tags/Apple/clang-318.0.61)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.polynomial.legendre.leggauss(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'leggauss'
>>> numpy.version.version
'1.6.1'

最佳答案

如果您点击source在文档中,您会看到它是在版本 1.7.0 中添加的注释。

def leggauss(deg):
"""
Gauss-Legendre quadrature.

Computes the sample points and weights for Gauss-Legendre quadrature.
These sample points and weights will correctly integrate polynomials of
degree :math:`2*deg - 1` or less over the interval :math:`[-1, 1]` with
the weight function :math:`f(x) = 1`.

Parameters
----------
deg : int
Number of sample points and weights. It must be >= 1.

Returns
-------
x : ndarray
1-D ndarray containing the sample points.
y : ndarray
1-D ndarray containing the weights.

Notes
-----

.. versionadded::1.7.0

关于python - numpy 1.6.1 未找到多项式对象的求积属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894142/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com