This page was generated from /build/reproducible-path/esda-2.5.0/docs/notebooks/joincounts.ipynb. Interactive online version: Binder badge

[1]:
import libpysal as lps
import numpy as np
import esda
import matplotlib.pyplot as plt
%matplotlib inline
[3]:
w = lps.weights.lat2W(4, 4)
y = np.ones(16)
y[0:8] = 0
np.random.seed(12345)
from esda.join_counts import Join_Counts
jc = Join_Counts(y, w)
jc.bb

[3]:
10.0
[4]:
jc.crosstab
[4]:
Neighbor W B
Focal
W 10.0 1.0
B 3.0 10.0
[5]:
jc.expected
[5]:
Neighbor W B
Focal
W 5.958333 5.041667
B 7.041667 5.958333
[6]:
jc.chi2
[6]:
8.479632255856034
[7]:
jc.chi2_p
[7]:
0.003591446953916693
[10]:
jc.p_sim_chi2
[10]:
0.002
[11]:
import seaborn as sns
[12]:
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_chi2, rug=True, hist=False, ax=ax)
plt.axvline(jc.chi2, 0,0.17, color='r')

[12]:
<matplotlib.lines.Line2D at 0x7f3fecbd5be0>
../_images/notebooks_joincounts_8_1.png
[16]:
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_bb, rug=True, hist=False, ax=ax)
plt.axvline(jc.bb, 0,0.17, color='r')
plt.title('BB Counts')

[16]:
Text(0.5, 1.0, 'BB Counts')
../_images/notebooks_joincounts_9_1.png
[15]:
f, ax = plt.subplots(1, figsize=(9, 9))
sns.distplot(jc.sim_bw, rug=True, hist=False, ax=ax)
plt.axvline(jc.bw, 0,0.17, color='r')
plt.title('WW Counts')

[15]:
Text(0.5, 1.0, 'WW Counts')
../_images/notebooks_joincounts_10_1.png
[ ]: