Python Programming for Biology: Bioinformatics and Beyond


part  of  that  difference,  for  a  continuous  random  variable



Download 7,75 Mb.
Pdf ko'rish
bet352/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   348   349   350   351   352   353   354   355   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming


part  of  that  difference,  for  a  continuous  random  variable,  X,  we  now  have  a  probability

density function,  f(x).

11

 The  probability  density  function  for  the  normal  distribution  is  as



follows:

We use the normal distribution to model the distribution of heights in a population of

male humans, where we might say the mean (μ) is 1.76 and the standard deviation (σ)  is

0.075,  and  we  plot  f(x).  Here  we  illustrate  with  Python  using  the  stats.norm()  function

directly,  with  the  required  mean  and  standard  deviation,  to  obtain  an  object  representing

the  random  variable  (normRandVar).  We  can  then  use  this  object  to  calculate  the

probability  density  function  for  an  array  of  values,  which  here  represent  a  range  of  the

horizontal x axis that we will plot (see

Figure 22.4

for a labelled version of the output). It

is notable that the function we call is .pdf(), which is distinct from the .pmf() used for the

discrete probability distributions.

from matplotlib import pyplot

from scipy.stats import norm

from numpy import arange

mean = 1.76

stdDev = 0.075

stepSize = 0.0001

normRandVar = norm(mean, stdDev) # Random variable object

xVals = arange(1.42, 2.1, stepSize) # Graph range

yVals = normRandVar.pdf(xVals) # Note PDF not PMF

pyplot.plot(xVals, yVals, color='black')

Then  we  can  also  plot  the  regions  corresponding  to  one  and  two  standard  deviation

widths  using  the  handy  pyplot.fill_between()  function,  which  in  this  case  fills  the  area

from the tail region of the curve to the x axis (y = 0).

xVals = arange(mean-2*stdDev, mean+2*stdDev, stepSize)

yVals = normRandVar.pdf(xVals)

pyplot.fill_between(xVals, yVals, 0, color='lightgrey')

xVals = arange(mean-stdDev, mean+stdDev, stepSize)

yVals = normRandVar.pdf(xVals)

pyplot.fill_between(xVals, yVals, 0, color='grey')

pyplot.show()





Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   348   349   350   351   352   353   354   355   ...   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