1
2
3
4
5
6
7 package yawn.util;
8
9 import junit.framework.TestCase;
10
11 /***
12 * This is yawn.util.PatternTest, part of the yawn project.
13 *
14 * <p>$Id: PatternTest.java,v 1.5 2005/04/20 18:55:18 supermarti Exp $</p>
15 *
16 * @author Luis Martí (luis dot marti at uc3m dot es)
17 * @version $Revision: 1.5 $
18 */
19 public class PatternTest extends TestCase {
20
21
22
23
24 protected void setUp() throws Exception {
25 super.setUp();
26 }
27
28 public final void testDist() {
29
30 }
31
32 public final void testInnerProduct() {
33
34 }
35
36 public final void testNorm1() {
37
38 }
39
40 public final void testNorm2() {
41
42 }
43
44 protected static final int RAND_AMOUNT = 1000;
45
46 protected static final double RAND_EPSILON = 0.05;
47
48 protected static final double MIN_BOUND = 5.0;
49
50 protected static final double MAX_BOUND = 6.0;
51
52 protected static final double EXPTD_MEAN = (MAX_BOUND + MIN_BOUND) / 2;
53
54 public final void testRandomize() {
55 double tot = 0;
56 for (int i = 0; i < RAND_AMOUNT; i++) {
57 Pattern pat = new Pattern(1);
58 pat.randomize(5, 6);
59 double value = pat.asDoubleArray()[0];
60 assertTrue("Samples are in the interval [" + MIN_BOUND + "," + MAX_BOUND + "]",
61 value >= 5);
62 assertTrue("Samples are in the interval [" + MIN_BOUND + "," + MAX_BOUND + "]",
63 value <= 6);
64 tot += value;
65 }
66 tot = tot / RAND_AMOUNT;
67 assertTrue("Uniform random in [" + MIN_BOUND + "," + MAX_BOUND + "] has approx mean "
68 + EXPTD_MEAN, Math.abs(EXPTD_MEAN - 5.5) < RAND_EPSILON);
69 }
70 }