Changeset 344 for trunk/EventBenchCoreTest/src/de
- Timestamp:
- 12/22/11 10:13:18 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/EventBenchCoreTest/src/de/ugoe/cs/eventbench/models/FirstOrderMarkovModelTest.java
r343 r344 1 1 package de.ugoe.cs.eventbench.models; 2 2 3 import java.util.ArrayList; 4 import java.util.Collection; 5 import java.util.List; 3 6 import java.util.Random; 4 7 import org.junit.*; 8 9 import de.ugoe.cs.eventbench.data.Event; 5 10 import static org.junit.Assert.*; 6 11 … … 14 19 public class FirstOrderMarkovModelTest { 15 20 21 Collection<List<? extends Event<?>>> sequences; 22 16 23 @Test 17 24 public void testFirstOrderMarkovModel_1() throws Exception { … … 29 36 new FirstOrderMarkovModel(null); 30 37 } 38 39 @Test 40 public void testCalcEntropy() throws Exception { 41 Random r = new Random(); 42 FirstOrderMarkovModel fixture = new FirstOrderMarkovModel(r); 43 fixture.train(sequences); 44 45 double result = fixture.calcEntropy(); 46 47 assertEquals(0.7392d, result, 0.0001); 48 } 49 50 @Before 51 public void setUp() throws Exception { 52 List<Event<?>> sequence = new ArrayList<Event<?>>(); 53 sequence.add(new Event<String>("a")); 54 sequence.add(new Event<String>("b")); 55 sequence.add(new Event<String>("r")); 56 sequence.add(new Event<String>("a")); 57 sequence.add(new Event<String>("c")); 58 sequence.add(new Event<String>("a")); 59 sequence.add(new Event<String>("d")); 60 sequence.add(new Event<String>("a")); 61 sequence.add(new Event<String>("b")); 62 sequence.add(new Event<String>("r")); 63 sequence.add(new Event<String>("a")); 64 65 sequences = new ArrayList<List<? extends Event<?>>>(); 66 sequences.add(sequence); 67 } 31 68 32 69 public static void main(String[] args) {
Note: See TracChangeset
for help on using the changeset viewer.