Ejemplo n.º 1
0
 public void Base_ExpectedValueGeneric()
 {
     var P = 0.5;
     var X = new Bernoulli(P);
     double E = X.ExpectedValueWithConfidence().Mean;
     var Err = Math.Abs(E - P);
     Assert.IsTrue(Err < eps);
 }
Ejemplo n.º 2
0
 public void Base_SampleCaching()
 {
     var X = new Bernoulli(0.5);
     var NotX = from a in X select !a;
     var XorNotX = from a in X from b in NotX select a | b;
     //var A = X | !X;
     // Without sample caching we get Prob = 0.75
     var Prob = XorNotX.ExpectedValueWithConfidence(100000);
     Assert.IsTrue(ApproxEqual (Prob.Mean, 1.0));
 }