package net.woodyfolsom.msproj.ann2;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import net.woodyfolsom.msproj.ann2.math.ActivationFunction;
import net.woodyfolsom.msproj.ann2.math.Tanh;

import org.junit.Test;

public class TanhTest {
	static double EPS = 0.001;
	
	@Test
	public void testCalculate() {
		
		ActivationFunction tanh = new Tanh();
		assertEquals(0.0,tanh.calculate(0.0),EPS);
		assertTrue(tanh.calculate(100.0) > 0.5 - EPS);
		assertTrue(tanh.calculate(-9000.0) < -0.5 + EPS);
	}
	
	@Test
	public void testDerivative() {
		ActivationFunction tanh = new Tanh();
		assertEquals(1.0,tanh.derivative(0.0), EPS);
	}
}
