#include #include #include #define FROM 0.0 #define TO 100.0 #define STEP 0.01 #define INPUT 0.1 #define INITIAL_VALUE -10.0 #define sigmoid_slope -1.0 typedef struct { double output; double inner_state; double thres; double inp_wgt; } neuron; void initialize_neuron(neuron *a) { a->output = 0.0; a->inner_state = INITIAL_VALUE; a->thres = 0.0; a->inp_wgt = 1.0; } double output_f(double value) { return 1.0 / ( 1.0 + exp(sigmoid_slope * value) ); } void update_neuron(neuron *a, double input) { a->inner_state += (- a->output + a->inp_wgt * input - a->thres) * STEP; a->output = output_f(a->inner_state); } int main(int argc, char **argv) { neuron a; double t; initialize_neuron(&a); t = FROM; while ( t <= TO ){ update_neuron(&a, INPUT); printf("%f %f\n", t, a.output); t += STEP; } return EXIT_SUCCESS; }