Python Programming for Biology: Bioinformatics and Beyond


Figure 22.8.  The Pearson correlation coefficient that rejects an uncorrelated



Download 7,75 Mb.
Pdf ko'rish
bet363/514
Sana30.12.2021
Hajmi7,75 Mb.
#91066
1   ...   359   360   361   362   363   364   365   366   ...   514
Bog'liq
[Tim J. Stevens, Wayne Boucher] Python Programming

Figure 22.8.  The Pearson correlation coefficient that rejects an uncorrelated

hypothesis at the 5% level for different sample sizes. For two uncorrelated random

variables the likelihood of coincidentally obtaining a Pearson correlation coefficient (r)

substantially different from zero diminishes with increasing sample size. The graph shows,

for different sample sizes, the threshold value of r that will be exceeded 5% of the time by

truly uncorrelated normal distributions.

Simple linear regression

Related to the linear correlation coefficient is the notion of the line of best fit. Although

there are various ways to calculate such a line, Pearson’s correlation coefficient provides a

handy  way  of  doing  a  line  fit  called  simple  linear  regression.  For  reasons  we  won’t  go

into,  it  can  be  shown  that  the  covariance  of  X  and  Y  divided  by  the  variance  of  X  is  the

gradient  of  the  line  that  minimises  the  sum  of  the  squared  differences  along  the  Y  axis,

from the fit line to the data points. Hence the gradient β can be written as this ratio, which

in turn may be derived from the correlation coefficient:

Following from this, the intersection of the Y axis, α can be calculated as:

α = μ


y

− β


μx

This is all very easy to do in Python using NumPy functions, noting that as before we test

with some artificial values derived from a random sample:

from numpy import cov, var, mean, random

xVals = random.normal(0.0, 1.0, 100)

yVals = 2.0 + -0.7 * xVals + random.normal(0.0, 0.2, 100)

grad = cov(xVals, yVals)/var(xVals, ddof=1)

yInt = mean(yVals) – grad * mean(xVals)

print('LR 1:', grad, yInt) # Result for one run was: -0.711 2.04




Download 7,75 Mb.

Do'stlaringiz bilan baham:
1   ...   359   360   361   362   363   364   365   366   ...   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