Over a million developers have joined DZone.

Customizable Sigmoid Function

·

/**
 * Calculates S-curve for point x in the interval 0 .. normV
 * 
 * @param x input coordinate
 * @param normV scale value which corresponds to 1.0 if x is normalized
 * @param sharpness adjusts steepness of curve (value of 1 equals undistorted sigmoid)
 *
 * @return sigmoid for point X
 */
public float sigmoid(float x, float normV, float sharpness) {
  x=(x/normV*2-1)*5*sharpness;
  return 1.0f / (1.0f + (float)Math.exp(-x));
}

public double sigmoid(double x, double normV, double sharpness) {
  x=(x/normV*2-1)*5*sharpness;
  return 1.0 / (1.0 + Math.exp(-x));
}
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}