Python Programming for Biology: Bioinformatics and Beyond



Download 7,75 Mb.
Pdf ko'rish
bet118/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   114   115   116   117   118   119   120   121   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Multi-dimensional arrays

The  term  dimension  is  often  used  in  popular  parlance  to  describe  the  number  of

independent axes that can be used to span a given space. So, for example, the coordinate

(x,y,z) of an atom location is often said to be a point in three-dimensional space, and if you

add a time coordinate, t, then you have a point, (x,y,z,t), in four-dimensional space-time.

Theoretical  physicists,  or  at  least  some  of  them,  are  happy  to  work  even  in  10  and  24

dimensions.

In  Python,  especially  when  using  the  NumPy  module,  you  will  often  come  across  the

word ‘dimension’ used in a different way, as an indication of the rank; how many axes are

needed to describe an array of numbers, rather than the size of the space they operate on.

The  dimension  of  an  array  can  be  defined  as  the  number  of  indices  that  are  required  to

specify  an  element  of  the  array.  For  example,  with  a  vector,  w,  we  specify  an  element

using one index, for example, w[m]. With a matrix we use two indices, for example, T[m]



[n]. Thus vectors have dimension one and matrices dimension two, even if both work in

real 3D space, and it is possible to have arrays of higher dimension. The vector (x, y, z) is

said  to  have  size  3.  When  using  Python’s  numpy  module  we  can  define  a  matrix  as  a

single array object, rather than a list of lists. In this case we would use combined indices

like T[m,n] to access elements and the size of the array is referred to, perhaps confusingly,

as its shape; so a 2×3 matrix is said to have shape (2, 3), and total size 2×3 = 6. Note that

an array in NumPy can be of any size, and thus may describe vectors and matrices.

We  will  mostly  use  the  NumPy  terminology  in  this  chapter  when  we  consider  multi-

dimensional arrays. However, as we illustrate below, we can implement the functionality

of multi-dimensional arrays in Python ourselves, using lists of lists etc., if we cannot or do

not want to import the numpy module.


Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   114   115   116   117   118   119   120   121   ...   514




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish