-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathneuron2.h
More file actions
96 lines (76 loc) · 2.28 KB
/
neuron2.h
File metadata and controls
96 lines (76 loc) · 2.28 KB
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
89
90
91
92
93
94
95
#include <iostream>
#include <cmath>
/* exponential firing model */
double generator(double min, double max){
double r_number = (double)rand()/RAND_MAX;
double range = max-min;
return min+range*r_number;
};
class Neuron {
public:
double u; // voltage across the neuron
double f_threshhold;// firing threshhold
double r_threshhold;// reset threshhold
double r; // resistance of the membrane
double c; // capacity of the activation
double delta_t; // shrapness of the peak
double u_rest; // relaxed voltage
double u_reset; // reset voltage
double tau; // charactaristic time
void init(double u,
double f_threshhold,
double r_threshhold,
double r,
double c,
double delta_t,
double u_rest,
double u_reset);
double du(double dt,double in_current);
void step(double dt,double in_current);
};
void Neuron::init(double u_in,
double f_threshhold_in,
double r_threshhold_in,
double r_in,
double c_in,
double delta_t_in,
double u_rest_in,
double u_reset_in){
u = u_in;
f_threshhold = f_threshhold_in;
r_threshhold = r_threshhold_in;
r = r_in;
c = c_in;
delta_t = delta_t_in;
u_rest = u_rest_in;
u_reset = u_reset_in;
tau = r*c;
}
double Neuron::du(double dt,double in_current) {
if (u < r_threshhold) {
double result;
result = u_rest-u;
result += delta_t*exp((u-f_threshhold)/delta_t)+r*in_current;
result += delta_t*exp((u_reset-u)/delta_t);
result += generator(-2,2);
return fmin(result,r_threshhold-u);
} else {
return u_reset-u;
}
}
void Neuron::step(double dt,double in_current){
u += du(dt,in_current);
}
/*int main(){
Neuron Alpha;
Alpha.init(-0.5,15.,40.,5.,0.4,1.,1.,-3.);
double t;
cout << "t u f_threshhold r_threshhold" << endl;
for(t = 0;t<40;t+=0.005){
Alpha.step(0.01,);
cout << t << " " << Alpha.u << " ";
cout << Alpha.f_threshhold << " ";
cout << Alpha.r_threshhold << endl;
}
return 0;
}*/