In [1]:
%pylab inline
In [2]:
from scipy.stats import norm
With mean 50 and standard deviation 10
In [5]:
# Create a normal distribution
mu = 50
sigma = 10 # standard deviation
rv = norm(loc = mu, scale = sigma)
start = rv.ppf(0.00001)
stop = rv.ppf(0.99999)
x = np.linspace(start, stop, 100)
print(start, stop)
plt.plot(x, rv.pdf(x))
plt.xlabel('Cells IDs'), plt.ylabel('Conductance');
plt.xlim(0,100);
In [8]:
# generate empirical distribution
cell_idx = np.arange(int(start), int(stop))
mycond = [rv.pdf(i) for i in cell_idx]
print(mycond[50])
In [9]:
plt.bar( cell_idx, mycond, width=.85, facecolor='k', label='empirical');
plt.xlabel('Cells IDs'), plt.ylabel('Conductance');
note that cells with ID <12 or > 87 receive almost zero conductance (check sigma)
In [10]:
rv.pdf(87)
Out[10]:
In [12]:
plt.plot(x, rv.pdf(x), c='r')
plt.bar( cell_idx, mycond, width=.85, facecolor='k', label='empirical');
plt.xlabel('Cells IDs'), plt.ylabel('Conductance');
let's generate another distribution with mean = 0 and standar deviation of 10
In [13]:
rv2 = norm(loc = 0, scale = 10)
start = rv2.ppf(0.0001)
stop = rv2.ppf(0.9999)
x = np.linspace(start, stop, 100)
mycond = [rv2.pdf(i) for i in x]
print(start, stop)
In [15]:
cell_idx = np.arange(int(start), int(stop))
mycond = [rv2.pdf(i) for i in cell_idx]
plt.plot(x, rv2.pdf(x), color = 'red')
plt.bar( cell_idx, mycond, width=.85, facecolor='k', label='empirical');
plt.xlabel('Cells IDs'), plt.ylabel('Conductance');
In [22]:
rv3 = norm(loc = 0, scale = 20)
start = rv3.ppf(0.0001)
stop = rv3.ppf(0.9999)
x = np.arange(start, stop)
plt.plot(x, rv3.pdf(x)/10, 'red')
print(start, stop)
In [ ]: