public void DiceProbabilityTest() { int success = 0; var tryCount = 60000; var rnd = new UniformRandomizer(new Interval<double>(1.0, 7.0, IntervalKind.ClosedOpen)); //(1.0, 6.9999999); Parallel.For(1, tryCount, k => { var m = new int[6]; var check = 1; for(var i = 0; i < 13; i++) { int result = (int)rnd.Next() - 1; m[result]++; } for(var i = 0; i < 6; i++) if(m[i] == 0) { check = 0; break; } if(check == 1) Interlocked.Increment(ref success); }); var prob = (success / (double)tryCount) * 100.0; if(IsDebugEnabled) log.Debug("Success probability = {0}", prob); }
public void DiceProbabilityTest() { int success = 0; var tryCount = 60000; var rnd = new UniformRandomizer(new Interval <double>(1.0, 7.0, IntervalKind.ClosedOpen)); //(1.0, 6.9999999); Parallel.For(1, tryCount, k => { var m = new int[6]; var check = 1; for (var i = 0; i < 13; i++) { int result = (int)rnd.Next() - 1; m[result]++; } for (var i = 0; i < 6; i++) { if (m[i] == 0) { check = 0; break; } } if (check == 1) { Interlocked.Increment(ref success); } }); var prob = (success / (double)tryCount) * 100.0; if (IsDebugEnabled) { log.Debug("Success probability = {0}", prob); } }