Esempio n. 1
0
        public void bs_nlz()
        {
            var src = Random.BitStrings(5, 60).Take(Pow2.T14);

            foreach (var bs in src)
            {
                var bvX  = bs.TakeValue <ulong>().ToBitString();
                var nlzX = bvX.PopCount();
                var bv   = bs.ToBitVector(n64);
                var nlzY = bv.Pop();
                Claim.eq(nlzX, nlzY);
            }
        }
Esempio n. 2
0
        public void distribution()
        {
            const int len     = 16 * 16;
            var       samples = Pow2.T16;
            var       stats   = Collector.Create();
            var       src     = Random.BitStrings(len);

            for (var i = 0; i < samples; i++)
            {
                stats.Collect(src.First().PopCount());
            }

            var ideal  = len / 2.0;
            var actual = stats.Mean;
            var delta  = math.abs(actual - ideal).Round(6);

            Claim.yea(delta < .01);
        }