public void TestDan() { var r = new RandomMath(); int N = 50; // Generate an array of independent estimates of whether a signal // is high or low Uncertain <bool>[] data = (from i in Enumerable.Range(0, N) let noise = r.NextGaussian(0, 0.01) let vad = i > 15 && i < 30 ? 0.9 : 0.1 let param = Math.Abs(vad + noise) let f = new Bernoulli(param > 1 ? 1 : param) select f).ToArray(); // history operator we chatted about Uncertain <bool[]> history = data.USeq(N); // Inference computes a weighted bool[] object: effectively a histogram // The call to SampledInference needs to know (i) how many samples to take and how to compare bool[] Uncertain <bool[]> posterior = history.SampledInference(10000, new SequenceComparer <bool>()); // now inspect by materializing a list List <Weighted <bool[]> > top5 = posterior .Support() // enumerate the histogram .OrderByDescending(k => k.Probability) // sorted by probability .Take(5) // just top 5 .ToList(); // produce list //var program = from bools in history // let sum = bools.Select(Convert.ToInt32).Sum() // from prior in new Gaussian(20, 0.01) // where sum == (int) prior // select bools; //Uncertain<bool[]> posterior1 = program.SampledInference(10000, new BoolArrayEqualityComparer()); Func <bool[], bool[]> Intervalize = _ => _; var program = from bools in data.USeq(N) select Intervalize(bools); // now inspect by materializing a list List <Weighted <bool[]> > top51 = posterior .Support() // enumerate the histogram .OrderByDescending(k => k.Probability) // sorted by probability .Take(5) // just top 5 .ToList(); // produce list // set breakpoint int x = 10; }