//
用来计算从-4到4之间的sigmoid函数值的静态函数
public
class
Uitility
...
{
public static PointF[] GetPoints()
...{
PointF[] mypos=new PointF[400];
int j=0;
for(double i=-4;i<=4;i+=0.02)
...{
mypos[j]= new PointF((float)i,(float)Sigmoid(i));
j++;
}
return mypos;
}
public static double Sigmoid(double x)
...{
return 1/(1+Math.Pow(Math.E,-x));
}
}


//
调用函数,完成函数的picturebox1上的绘制
Graphics grfx
=
pictureBox1.CreateGraphics();
int
picwidth
=
pictureBox1.Width;
int
picheight
=
pictureBox1.Height;
float
midx
=
(
float
)picwidth
/
2
;
float
midy
=
(
float
)picheight
/
2
;

Pen bb
=
new
Pen(Brushes.Black,
2
);
grfx.DrawLine(Pens.Red,
new
Point(
0
,picheight
-
1
),
new
Point(picwidth,picheight
-
1
));
//
横坐标
grfx.DrawLine(Pens.Red,
new
Point((
int
)midx,picheight),
new
Point((
int
)midx,
0
));
PointF[] cc
=
Uitility.GetPoints();
PointF[] realone
=
new
PointF[cc.Length];
int
cclen
=
cc.Length; 
//
将与坐标无关的数值转换成与坐标相关的点
for
(
int
i
=
0
;i
<
cclen;i
++
)
...
{
float fx=cc[i].X*picwidth/8+midx;
float fy=cc[i].Y*picheight;
realone[i]=new PointF(fx,-fy+picheight);
}
grfx.DrawLines(bb,realone);