import numpy as np
recordingTime = np.array([10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200])
tenSpikeTrains = np.array([[0,0,0,0,0,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0],\
[0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0,0,0],\
[1,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0],\
[0,0,0,0,0,0,0,1,1,0,1,0,0,0,0,0,0,1,0,0],\
[0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0],\
[0,0,0,0,0,0,0,0,0,1,1,0,0,0,1,0,0,0,1,0],\
[0,0,0,0,0,0,0,1,1,1,0,0,1,1,0,0,1,1,0,0],\
[0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,1,0,0,0,0],\
[0,0,0,0,0,0,0,1,1,0,0,1,1,0,0,1,1,0,0,0],\
[0,0,0,0,0,1,0,0,1,0,1,0,0,0,0,0,1,1,0,0]])
number_of_spikes=[]
for j in range (len(tenSpikeTrains[0])):
number_of_spikes.append(np.sum(tenSpikeTrains[:,j]))
print ("The total number of spikesfor each time bin is",number_of_spikes)
import matplotlib.pyplot as plt
plt.bar(recordingTime, number_of_spikes, color="black",width=3)
plt.show()
mean_number_of_spikes=[]
for j in range (len(tenSpikeTrains[0])):
mean_number_of_spikes.append(np.sum(tenSpikeTrains[:,j]))
plt.bar(recordingTime,mean_number_of_spikes)
plt.show()
print("The average firing rate across trials is",(np.sum(number_of_spikes)*1000)/(recordingTime[-1]*10),'spikes/s')