Numpy (Python) by 바죠


파이썬에서 널리 사용되어 오던 패키지, Numeric이 더이상 개발되지 않는다고 한다. 물론, 계속 사용할 수는 있다.

cf. 파이썬 설치(리눅스에 설치):
http://incredible.egloos.com/3580524

오래된 패키지, Numeric 은 더이상 개발되지 않는다.
numpy를 사용해야 한다. 파이썬을 설치하고 그 다음에 numpy를 설치한다.
http://numpy.scipy.org//
 
http://www.scipy.org/Numpy_Example_List#all  : NumPy example list.

form Numeric import *
대신에
from  numpy.oldnumeric import *
를 사용하면 된다.

from pylab import *
를 사용해도 numpy내용물들을 활용할 수 있다.
-------------------
Numeric (version 24.2)
Maintenance has ceased for Numeric, and users should transisition to NumPy as quickly as possible.
 

-------------------
Documentation for Numeric:
numpy.pdf


=================================================================
Python 2.4.4 (#2, Apr  5 2007, 18:43:10)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from numpy.fft import fft
>>> from numpy import array
>>> a=((1.,2.,3.,2.,1.,2.,3.,2.,1.))
>>> fft(a)
array([ 17.        +0.j        ,  -1.15270364-0.41954982j,
        -3.37938524-2.83564091j,   0.5       +0.8660254j ,
         0.03208889+0.18198512j,   0.03208889-0.18198512j,
         0.5       -0.8660254j ,  -3.37938524+2.83564091j,
        -1.15270364+0.41954982j])
>>> b=array([1.,2.,3.,2.,1.,0.,4.,2.,1.])
>>> fft(b)
array([ 16.        +0.j        ,   0.2266816 -0.2375647j ,
        -5.41147413-2.41609109j,   2.5       -0.8660254j ,
        -0.81520747+3.01762603j,  -0.81520747-3.01762603j,
         2.5       +0.8660254j ,  -5.41147413+2.41609109j,
         0.2266816 +0.2375647j ])
>>>
>>> a=array([1.,2.,4.],[4., 6., 7.],[3.,4.,9.9])
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: only 2 non-keyword arguments accepted
>>> a=array([[1.,2.,4.],[4., 6., 7.],[3.,4.,9.9]])
>>> b=array([9.,7.,8.])
>>> print det(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'det' is not defined
>>> from numpy.linalg import *
>>> det(a)
-13.800000000000001
>>> inv(a)
array([[-2.27536232,  0.27536232,  0.72463768],
       [ 1.34782609,  0.15217391, -0.65217391],
       [ 0.14492754, -0.14492754,  0.14492754]])
>>> solve(a,b)
array([-12.75362319,   7.97826087,   1.44927536])
>>> eig(a)
(array([ 15.02143919,  -0.40270865,   2.28126946]), array([[-0.29121818, -0.88026732,  0.03118467],
       [-0.66371318,  0.46861119, -0.88996086],
       [-0.68896791,  0.07438405,  0.45496942]]))


Numpy main features:
  • An N-dimensional array object.

  • A collection of fast math functions.

  • Basic linear algebra support (module: linalg).

  • Basic Fourier Transform support (module: fft).

  • Random number generation capabilities (module: random).

numpy.fft
numpy.linalg
numpy.random
numpy.oldnumeric

=================================================================================
Python 2.4.4 (#2, Apr  5 2007, 18:43:10)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy.fft
>>> dir(numpy.fft)
['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'fft', 'fft2', 'fftfreq', 'fftn', 'fftpack', 'fftpack_lite', 'fftshift', 'helper', 'hfft', 'ifft', 'ifft2', 'ifftn', 'ifftshift', 'ihfft', 'info', 'irefft', 'irefft2', 'irefftn', 'irfft', 'irfft2', 'irfftn', 'refft', 'refft2', 'refftn', 'rfft', 'rfft2', 'rfftn', 'test']
>>> import numpy.linalg
>>> dir(numpy.linalg)
['LinAlgError', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'cholesky', 'det', 'eig', 'eigh', 'eigvals', 'eigvalsh', 'info', 'inv', 'lapack_lite', 'linalg', 'lstsq', 'norm', 'pinv', 'qr', 'solve', 'svd', 'tensorinv', 'tensorsolve', 'test']
>>> import numpy.random
>>> dir(numpy.random)
['RandomState', '__RandomState_ctor', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__path__', 'beta', 'binomial', 'bytes', 'chisquare', 'exponential', 'f', 'gamma', 'geometric', 'get_state', 'gumbel', 'hypergeometric', 'info', 'laplace', 'logistic', 'lognormal', 'logseries', 'mtrand', 'multinomial', 'multivariate_normal', 'negative_binomial', 'noncentral_chisquare', 'noncentral_f', 'normal', 'pareto', 'permutation', 'poisson', 'power', 'rand', 'randint', 'randn', 'random', 'random_integers', 'random_sample', 'ranf', 'rayleigh', 'sample', 'seed', 'set_state', 'shuffle', 'standard_cauchy', 'standard_exponential', 'standard_gamma', 'standard_normal', 'standard_t', 'test', 'triangular', 'uniform', 'vonmises', 'wald', 'weibull', 'zipf']

트랙백

이 글과 관련된 글 쓰기 (트랙백 보내기)
TrackbackURL : http://incredible.egloos.com/tb/3607490 [도움말]
  • GNUPLOT vs. MATPLOTLIB 2009/10/23 17:23 #

    결론 : 이러저러한 일로 gnuplot 을 리뷰해 보고 있는 중인데 그냥 matplotlib을 사용해야겠음 [개인적인 차트 품질 선호도 - 이미지로 만들어서 사용하는 경우] MATLAB > MATPLOTLIB > GNUPLOT [개인적인 차트 품질 선호도 - Interactive Mode] MATLAB > GNUPLOT > MATPLOTLIB ( i-python 미사용시 ) 그냥 참고 gnuplot 을 10여년전부터 사용해왔지만 결국은 matp...... more

핑백

덧글

덧글 입력 영역