<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 <H2>Generate random numbers with a given (numerical) distribution</H2>
Step1:  <H2> Theoretical distribution</H2>
With mean 50 and standard deviation 10
Step2:  <H2>Empirical distribution</H2>
Step3:  note that cells with ID <12 or > 87 receive almost zero conductance (check sigma)
Step4:  <H2> Plot both together </H2>
Step5:  let's generate another distribution with mean = 0 and standar deviation of 10
<ASSISTANT_TASK:>
Python Code:
%pylab inline
from scipy.stats import norm
Explanation: <H2>Generate random numbers with a given (numerical) distribution</H2>
End of explanation
# 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);
Explanation: <H2> Theoretical distribution</H2>
With mean 50 and standard deviation 10
End of explanation
# generate empirical distribution
cell_idx = np.arange(int(start), int(stop))
mycond = [rv.pdf(i) for i in cell_idx]
print(mycond[50])
plt.bar( cell_idx, mycond, width=.85, facecolor='k', label='empirical');
plt.xlabel('Cells IDs'), plt.ylabel('Conductance');
Explanation: <H2>Empirical distribution</H2>
End of explanation
rv.pdf(87)
Explanation: note that cells with ID <12 or > 87 receive almost zero conductance (check sigma)
End of explanation
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');
Explanation: <H2> Plot both together </H2>
End of explanation
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)
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');
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)
Explanation: let's generate another distribution with mean = 0 and standar deviation of 10
End of explanation
<END_TASK>