Correlation_range_dependence.svg
Size of this PNG preview of this SVG file:
450 × 360 pixels
.
Other resolutions:
300 × 240 pixels
|
600 × 480 pixels
|
960 × 768 pixels
|
1,280 × 1,024 pixels
|
2,560 × 2,048 pixels
.
Summary
Description Correlation range dependence.svg |
English:
Plot depicting how various measures of association are affected when the range of a quantitative variable is limited.
|
Date | |
Source | Own work |
Author | Skbkekas |
SVG development
InfoField
|
This plot was created with
Matplotlib
.
|
Source code
InfoField
|
Python codeimport numpy as np
import matplotlib.pyplot as plt
r = 0.9
X = np.random.normal(size=100)
Y = r*X + np.sqrt(1-r**2)*np.random.normal(size=100)
ii = np.flatnonzero( (X>0) * (X<1) )
XR = np.argsort(np.argsort(X))
YR = np.argsort(np.argsort(Y))
def pearson(X,Y):
cc = np.cov(X,Y)
return cc[0,1]/np.sqrt(cc[0,0]*cc[1,1])
r1 = pearson(X, Y)
r2 = pearson(X[ii], Y[ii])
s1 = pearson(XR, YR)
s2 = pearson(XR[ii], YR[ii])
plt.clf()
plt.hold(True)
plt.figure(figsize=(5,4))
plt.axes([0.13,0.13,0.8,0.8])
plt.fill((0,1,1,0,0), (-3,-3,3,3,-3), 'lightgrey', ec='lightgrey')
a = plt.plot(X, Y, 'o', color='orange')
b = plt.plot(X[ii], Y[ii], 'o', color='lightblue')
plt.xlim(-3,3)
plt.ylim(-3,3)
plt.xlabel("X", size=18)
plt.ylabel("Y", size=18)
bx = plt.legend((a,b), ["%.2f/%.2f" % (r1,s1), "%.2f/%.2f" % (r2,s2)],\
'upper left', numpoints=1, handletextpad=0.00001)
bx.draw_frame(False)
plt.savefig("correlation_range_dependence.pdf")
plt.savefig("correlation_range_dependence.svg")
|
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the
Creative Commons
Attribution 3.0 Unported
license.
-
You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
-
Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.