public void TestExceptions() { // Exception suma 0 var probs = new ListaProbabilidad<int> (z => z); Assert.Throws (typeof (ListaProbabilidad<int>.NotMeasureException), new TestDelegate (delegate { probs.Select (); })); Assert.Throws (typeof (ListaProbabilidad<int>.NotMeasureException), new TestDelegate (delegate { probs.Add (-3); probs.Select (); })); }
public void TestExceptions() { // Exception suma 0 var probs = new ListaProbabilidad <int> (z => z); Assert.Throws(typeof(ListaProbabilidad <int> .NotMeasureException), new TestDelegate(delegate { probs.Select(); })); Assert.Throws(typeof(ListaProbabilidad <int> .NotMeasureException), new TestDelegate(delegate { probs.Add(-3); probs.Select(); })); }
public void Test() { var prob = new ListaProbabilidad <int> (z => z); var res = new Dictionary <int, double> (10); for (int i = 0; i < 10; i++) { prob.Add(i); res.Add(i, 0); } const int numPruebas = 100000; for (int i = 0; i < numPruebas; i++) { var ind = prob.Select(); res [ind]++; } Assert.AreEqual(10, prob.Count); const double expFactor = numPruebas / 45.0; // Imprimir resultados for (int i = 0; i < 10; i++) { var expect = expFactor * i; var errAbs = expect - res [i]; var errRel = errAbs / expect; if (i > 0) { Assert.True(Math.Abs(errRel) < 0.1); } Console.WriteLine("{0}\t\tE = {1}:\t\t{2}", res [i], expect, errRel); } }
public void Test() { var prob = new ListaProbabilidad<int> (z => z); var res = new Dictionary<int, double> (10); for (int i = 0; i < 10; i++) { prob.Add (i); res.Add (i, 0); } const int numPruebas = 100000; for (int i = 0; i < numPruebas; i++) { var ind = prob.Select (); res [ind]++; } Assert.AreEqual (10, prob.Count); const double expFactor = numPruebas / 45.0; // Imprimir resultados for (int i = 0; i < 10; i++) { var expect = expFactor * i; var errAbs = expect - res [i]; var errRel = errAbs / expect; if (i > 0) Assert.True (Math.Abs (errRel) < 0.1); Console.WriteLine ("{0}\t\tE = {1}:\t\t{2}", res [i], expect, errRel); } }