/* lab090423p.c Simple Neuron 2009.4.23 A.Date Last modifield at 1 May 2009 % gcc lab090423p.c -lm */ #include #include /* drand48 */ #include /* log */ #define MAX_SAMPLES 1000 #define N_DIM 3 long int RAND_SEED = 20090423; int SLEEP = 50000; /* adjustment of display speed */ int N_DEMO = 30; int n_data; int n_data1 = 20; int n_data2 = 20; int n_trials = 100; /* number of learnings */ double eta = 0.1; /* learning coefficient */ double lambda=1.0; /* a parameter for sigmoid function */ double SIGMA = 1.0; char data_file1[] = "apples100.dat"; /* file name of data. need to change for project C,D */ char data_file2[] = "oranges100.dat"; double nrand(); double sigmoid(double x){ return 1.0/(1.0 + exp(-lambda*x)); } int main (int argc, char *argv[] ) { FILE *gp, *fp; int a,i,k,l,t, n; long int seed = RAND_SEED; int n_data; int teacher; double mu1x,mu1y,mu2x,mu2y; double y1, y2; double dw[N_DIM]; double w[N_DIM]; double data[MAX_SAMPLES][N_DIM]; double u,z,e,e2; double x_start = -5.0, x_end=5.0; double y_start = -5.0, y_end=5.0; for (i=1; i1.0 || s==0.0); s=sqrt(-2.0*log(s)/s); return(r1*s); } else { sw=0; return(r2*s); } }