Implementing Sigmoid Curves in C++

烂漫一生 提交于 2019-12-12 02:37:21

问题


I've been trying to implement Sigmoid curves since 12 hours ago and i could not manage to get it up.

I'm using Microsoft Visual Studio 2010.

The formula is y = 1/(1+exp(-e))

Yet when i try implementing in the codes it does not work, why? Can any experts please guide me along, thank you.

for(int y=0; y<bih.biHeight; y++)
{
for(int x=0; x<bih.biWidth; x++)
{   
SetPixel(hdc, (double)1/((double)1+exp(double(-x))), bih.biHeight-x, red);
}
}

回答1:


Your result for the (double)1/((double)1+exp(double(-x))) expression is between 0 and 1. You can't draw "subpixels" can you?

So to fix it, you need to multiply the result of the function by a value that will make it go through a visible range. For example:

(double)1/((double)1+exp(double(-x))) * bih.biHeight


来源:https://stackoverflow.com/questions/9065607/implementing-sigmoid-curves-in-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!