package analyzer;

public class ActivationFunction {

	public float[] applySigmoid(float[] netInput) {

		float[] netOutput = new float[netInput.length];

		for (int i = 0; i < netInput.length; i++) {

			float den = (float) (1 + Math.exp(-1 * (netInput[i])));
			netOutput[i] = 1 / den;

		}

		return netOutput;
	}

	public float[] applySigmoidDervative(float[] output) {

		float[] newOutput = new float[output.length];

		for (int i = 0; i < output.length; i++) {
			newOutput[i] = output[i] * (1 - output[i]);
		}

		return newOutput;
	}

	public float[] applyBinaryStep(float[] netInput) {

		float[] netOutput = new float[netInput.length];

		for (int i = 0; i < netInput.length; i++) {
			if (netInput[i] > 0)
				netOutput[i] = 1;
			else
				netOutput[i] = 0;
		}

		return netOutput;
	}
}
