public void AddOverflowEdgeTest() { MarkovChain <int> chains = new MarkovChain <int>(4); chains.AddEdge(0, 4, 0.2); chains.AddEdge(5, 6, 0.7); chains.AddEdge(7, 9, 0.1); Assert.That(0.2, Is.EqualTo(chains[0, 4])); Assert.That(0.1, Is.EqualTo(chains[7, 9])); }
public void GetOutgoingVerticesTest() { MarkovChain <int> chains = new MarkovChain <int>(4); chains.AddEdge(0, 4, 0.2); chains.AddEdge(5, 6, 0.7); chains.AddEdge(0, 5, 0.2); Assert.That(chains.GetOutgoingVertices(0), Is.EquivalentTo(new List <int> { 4, 5 })); }
public void GetRateTest() { MarkovChain <int> chains = new MarkovChain <int>(4); chains.AddEdge(0, 4, 0.2); chains.AddEdge(5, 6, 0.7); chains.AddEdge(7, 9, 0.1); Assert.That(0.2, Is.EqualTo(chains.GetRate(0, 4))); Assert.That(0.1, Is.EqualTo(chains.GetRate(7, 9))); Assert.That(0, Is.EqualTo(chains.GetRate(10, 11))); }
public void GetAllVerticesTest() { MarkovChain <int> chains = new MarkovChain <int>(4); chains.AddEdge(0, 4, 0.2); chains.AddEdge(5, 6, 0.7); chains.AddEdge(7, 9, 0.1); CollectionAssert.AreEquivalent(new List <int> { 0, 4, 5, 6, 7, 9 }, chains.GetAllVertices()); }
public void GetAllEdgesTest() { MarkovChain <int> chains = new MarkovChain <int>(7); chains.AddEdge(0, 1, 0.2); chains.AddEdge(0, 2, 0.7); chains.AddEdge(3, 2, 0.2); chains.AddEdge(4, 5, 0.2); CollectionAssert.AreEquivalent(new List <Tuple <int, double, int> > { new Tuple <int, double, int>(0, 0.2, 1), new Tuple <int, double, int>(0, 0.7, 2), new Tuple <int, double, int>(3, 0.2, 2), new Tuple <int, double, int>(4, 0.2, 5) }, chains.GetAllEdges()); }
public void AddEdgeTest() { MarkovChain <int> chains = new MarkovChain <int>(4); chains.AddEdge(0, 3, 0.2); chains[7, 10] = 0.7; Assert.That(0.2, Is.EqualTo(chains[0, 3])); Assert.That(0.7, Is.EqualTo(chains[7, 10])); }
public void GetComponentsTest() { MarkovChain <int> chains = new MarkovChain <int>(7); chains.AddEdge(0, 1, 0.2); chains.AddEdge(0, 2, 0.7); chains.AddEdge(3, 2, 0.2); chains.AddEdge(4, 5, 0.2); CollectionAssert.AreEquivalent(new List <List <int> > { new List <int> { 0, 1, 2, 3 }, new List <int> { 4, 5 }, new List <int> { 6 } }, chains.GetComponents(new List <int> { 0, 1, 2, 3, 4, 5, 6 }).Select(c => c.OrderBy(v => v).ToList()).ToList()); }
public void ComputeProbability() { double samplingRate = 0.5d; double timeSpan = 40.0d; double errorTolerance = 1e-16; MarkovChain <int> chains = new MarkovChain <int>(6); chains.InitialDistribution[1] = 0.9; chains.InitialDistribution[2] = 0.1; chains.InitialDistribution[3] = 0; chains.InitialDistribution[4] = 1; chains.InitialDistribution[5] = chains.InitialDistribution[6] = 0; chains.AddEdge(1, 2, 0.2d); chains.AddEdge(2, 1, 0.1d); chains[2, 3] = 0.1d; chains[3, 2] = 0.05d; chains[4, 5] = 0.1d; chains[5, 6] = 0.05d; var result = chains.ComputeProbability(samplingRate, timeSpan, errorTolerance); }