-1

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);
}
}
Newbie
  • 145
  • 2
  • 7
  • 23

1 Answers1

4

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
Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
  • SetPixel(hdc, (double)1/((double)1+exp(double(-x)))*bih.biWidth, bih.biHeight-x, red); Does not work :/ – Newbie Jan 30 '12 at 15:07
  • The lines start from nearly at the bottom right hand of the image, and ends it at the end with a slight curve on the top right hand of the image. Why is that so? – Newbie Jan 31 '12 at 00:00