Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

karsten schmidt http://toxi.co.uk

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

Customizable sigmoid function

   1  
   2  /**
   3   * Calculates S-curve for point x in the interval 0 .. normV
   4   * 
   5   * @param x input coordinate
   6   * @param normV scale value which corresponds to 1.0 if x is normalized
   7   * @param sharpness adjusts steepness of curve (value of 1 equals undistorted sigmoid)
   8   *
   9   * @return sigmoid for point X
  10   */
  11  public float sigmoid(float x, float normV, float sharpness) {
  12    x=(x/normV*2-1)*5*sharpness;
  13    return 1.0f / (1.0f + (float)Math.exp(-x));
  14  }
  15  
  16  public double sigmoid(double x, double normV, double sharpness) {
  17    x=(x/normV*2-1)*5*sharpness;
  18    return 1.0 / (1.0 + Math.exp(-x));
  19  }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS