1 16 17 package org.apache.commons.math.special; 18 19 import org.apache.commons.math.MathException; 20 21 import junit.framework.TestCase; 22 23 26 public class ErfTest extends TestCase { 27 28 public void testErf0() throws MathException { 29 double actual = Erf.erf(0.0); 30 double expected = 0.0; 31 assertEquals(expected, actual, 1.0e-5); 32 } 33 34 public void testErf1960() throws MathException { 35 double x = 1.960 / Math.sqrt(2.0); 36 double actual = Erf.erf(x); 37 double expected = 0.95; 38 assertEquals(expected, actual, 1.0e-5); 39 40 actual = Erf.erf(-x); 41 expected = -expected; 42 assertEquals(expected, actual, 1.0e-5); 43 } 44 45 public void testErf2576() throws MathException { 46 double x = 2.576 / Math.sqrt(2.0); 47 double actual = Erf.erf(x); 48 double expected = 0.99; 49 assertEquals(expected, actual, 1.0e-5); 50 51 actual = Erf.erf(-x); 52 expected = -expected; 53 assertEquals(expected, actual, 1.0e-5); 54 } 55 56 public void testErf2807() throws MathException { 57 double x = 2.807 / Math.sqrt(2.0); 58 double actual = Erf.erf(x); 59 double expected = 0.995; 60 assertEquals(expected, actual, 1.0e-5); 61 62 actual = Erf.erf(-x); 63 expected = -expected; 64 assertEquals(expected, actual, 1.0e-5); 65 } 66 67 public void testErf3291() throws MathException { 68 double x = 3.291 / Math.sqrt(2.0); 69 double actual = Erf.erf(x); 70 double expected = 0.999; 71 assertEquals(expected, actual, 1.0e-5); 72 73 actual = Erf.erf(-x); 74 expected = -expected; 75 assertEquals(expected, actual, 1.0e-5); 76 } 77 } 78 | Popular Tags |