PCG random number generator for .net

Due to one of my side projects needing to do Monte Carlo simulations, I was looking for a better random number generator than what the default Random class in .net offers. Unfortunately, I could not find any good ready-made random number generators for C#, so I decided to port the PCG random number generator to C#.

My pcg-random-csharp project implements the minimal C version of the PCG generator with the same interface as the default Random class. Thanks to this, it can be used as a direct drop-in replacement for the Random class in existing code without any modifications. The implemented generator has 64-bit internal state, and it produces 32-bit random numbers. By using the Pcg32(ulong state, ulong sequence) constructor, users can decide what random sequence they want to use. Please check the official PCG documentation on how the actual algorithm works.

Current installation method is to copy the Pcg32.cs file to your project. The Pcg32 class lives inside the PcgRandom namespace. In future, I will provide a Nuget package for easier installation. I also might add some other PCG generators to the library.