forked from justinbois/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathday3_exercise3.py
34 lines (28 loc) · 953 Bytes
/
day3_exercise3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import numpy as np
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns
#Create config for mathplotlib rc params
rc = {'lines.linewidth': 2, 'axes.labelsize': 18, 'axes.titlesize': 18}
sns.set(rc=rc)
#Load text
xa_high = np.loadtxt('data/xa_high_food.csv', comments = '#')
xa_low = np.loadtxt('data/xa_low_food.csv', comments = '#')
#Empirical cumulitive distribution function
def ecdf(data):
'''
Compute x, y values for an empirical distribution function
'''
x = np.sort(data)
y = np.arange(1, 1+len(x)) / len(x)
return x, y
x_high, y_high = ecdf(xa_high)
x_low, y_low = ecdf(xa_low)
plt.close()
plt.plot(x_high, y_high, marker='.', linestyle='none', markersize=20, alpha=0.5)
plt.plot(x_low, y_low, marker='.', linestyle='none', markersize=20, alpha=0.5)
plt.margins(0.03)
plt.xlabel('Cross-sectional area (µm)')
plt.ylabel('eCDF')
plt.legend(('high food', 'low food'), loc='lower right')
plt.show()