-
Notifications
You must be signed in to change notification settings - Fork 0
/
Finite_Spike_1D_loop_n101_G034_1_10.py
92 lines (74 loc) · 1.75 KB
/
Finite_Spike_1D_loop_n101_G034_1_10.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import matplotlib
matplotlib.use('Agg')
from numpy import *
import random
from pandas import *
for seed_ in range (1,11):
random.seed(seed_)
#Parametros
N=50 #numero de neuronios 2N+1
gama=0.34 #exponencia de tau_
T=[]
M=[]
T=T+[0]
M=M+[1]
sparce=10000*N #numero de interacao para salvar
tsparce=0
contador=0
max_contador=1000
#Periodo da semente random eh de 10^6.000
###############Iniciando variaveis#################
N=2*N+1
V=ones(N)
tau=zeros(2*N)
run_con=(sum(V)/N)
for i in range(N):
tau[i]=-log(random.random())
tau[i+N]=-(1.0/gama)*log(random.random())
###################################################
#print ( N, gama)
i=sparce
while ((run_con > 0) & (contador<max_contador)):
################ Evento #############################
t=min(tau)
n=argmin(tau)
if n<N:
if V[n]==1:
V[n]=0
if n<N-1: V[n+1]=1
if n>0: V[n-1]=1
else:
V[n-N]=0
#Sortear novos valores
tau=tau-t
if n<N:
tau[n]=-log(random.random())
else:
tau[n]=-(1.0/gama)*log(random.random())
run_con=(sum(V)/N)
tsparce=tsparce+t
i=i-1
if i==0:
T=T+[tsparce]
M=M+[run_con]
i=i+sparce
tsparce=0
contador=contador+1
#####################################################
T=T+[tsparce]
M=M+[run_con]
#i=i+sparce
#tsparce=0
################### Plot ################################
for i in range(1,len(M)): T[i]=T[i]+T[i-1]
'''
import matplotlib.pyplot as plt
plt.plot(T, M, 'k')
#plt.scatter(T, M, '.r', markersize=0.5)
plt.ylabel('media (S(1)/(2N+1))')
plt.xlabel('tempo (s)')
plt.ylim(0,1)
plt.xlim(0,T[i])
plt.savefig('plote_gama_' + str(gama) + '_n_'+str(N)+ '_seed_'+ str(seed_) + '_maxcontador_'+ str(max_contador)+'.png',dpi=300)
'''
print ( seed_, N, gama, T[i], contador)