RicardasSim

Sigmoid C

Dec 27th, 2023
1,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. double sigmoid(double x)
  6. {
  7.      return 1 / (1 + exp(-x));
  8. }
  9.  
  10. int main()
  11. {
  12.     double result;
  13.  
  14.     result = sigmoid(-10.0);
  15.  
  16.     printf("Sigmoid of -10.0: %f\n", result);
  17.  
  18.     result = sigmoid(0.0);
  19.  
  20.     printf("Sigmoid of 0.0: %f\n", result);
  21.  
  22.     result = sigmoid(10.0);
  23.  
  24.     printf("Sigmoid of 10.0: %f\n", result);
  25.  
  26.     return 0;
  27. }
  28.  
  29. /*
  30.  
  31. Sigmoid of -10.0: 0.000045
  32. Sigmoid of 0.0: 0.500000
  33. Sigmoid of 10.0: 0.999955
  34.  
  35. */
Advertisement