public void MCCoinSimulation_UniformRandom_Run_Test() { var settings = MCSimulationSettings.Create(numberTrials: 100000); var randomEngineService = new Random2DEngineService(); var coin = Coin.CreateWithDiameter(1.0); var squareTile = SquareTile.Create(2.0); var simulation = new MCCoinSimulation(settings, randomEngineService); simulation.Finished += results => { Assert.AreEqual(0.75, Math.Round(results.Probability, 2)); }; simulation.Run(coin: coin, squareTile: squareTile, method: SamplingMethod.RandomUniform); }
static void Main(string[] args) { var settings = MCSimulationSettings.Create(numberTrials: 1000000, reportEveryIteration: 10000); var randomEngineService = new Random2DEngineService(); var simulation = new MCCoinSimulation(settings, randomEngineService); simulation.ResultsUpdated += results => { var prop = (double)results.NumberOfHits / (double)results.Iteration; Console.WriteLine($"Iteration: {results.Iteration} " + $"Hits: {results.NumberOfHits} " + $"Probability: {prop}"); }; simulation.Finished += results => { Console.WriteLine($"MC simulation finished.\n{results}"); }; simulation.Run(Coin.CreateWithDiameter(1.0), SquareTile.Create(10.0), SamplingMethod.RandomUniform); Console.ReadKey(); }