// Sigmoid first and second derivatives numerical determination // Author : Gilles Carpentier // Faculte des Sciences et Technologies, // Universite Paris 12 Val de Marne, France. macro "Increasing Sigmoid Derivatives" { requires("1.42k"); x=newArray (0.8,0.82,0.84,0.86,0.88,0.90,0.92,0.94,0.96,0.98,1); y=newArray (14.8393,14.7143,14.7356,15.4157,16.9371,19.5372,22.9676,24.3529,24.9607,25.7170,25.7); derivatives (x,y); } macro "Decreasing Sigmoid Derivatives" { requires("1.42k"); x=newArray (0.0020,0.0152,0.0284,0.0416,0.0548,0.068,0.0812,0.0944,0.1076,0.1208); y=newArray (1.0361,0,-3.5905,-6.0928,-8.3546,-9.7343,-10.1599,-10.3712,-10.4371,-10.4889); derivatives (x,y); } function derivatives (x,y) { // Rotbard modeling Fit.logResults; Fit.doFit("Rodbard",x, y); Fit.plot(); rSquared1=Fit.rSquared; // sampling of the theoretical sigmoid obtained from fitting equation sampling=1000;REx=newArray(sampling); REy= newArray(sampling); xmin=getMin(x); xmax= getMax (x); step=(xmax-xmin)/sampling; for (i=0; i< sampling; i++) { REx[i]=xmin+(i+1)*step; REy[i]=Fit.f(REx[i]); } // first derivative firstDer=newArray (sampling); for (i=0; i< (sampling-1); i++) {firstDer[i]=REy[i+1]-REy[i];} // second derivative secundDer=newArray (sampling); for (i=0; i< (sampling-1); i++) {secundDer[i]=firstDer[i+1]-firstDer[i];} firstDer[sampling-1]=firstDer[sampling-2]; secundDer[sampling-1]=secundDer[sampling-3];secundDer[sampling-2]=secundDer[sampling-3]; //get the tangent of the sigmoid if (REy[0]