Fixing Random: Techniques in C#
Gain insights into tackling uncertainty in C# programming. Delve into improving System.Random class with powerful techniques for efficient problem-solving and fewer bugs. Discover new language uses.
Eric Lippert designs programming languages at Facebook. Other notable work includes designing C# analyzers at Coverity, and developing the Visual Basic, VBScript, JScript and C# compilers at Microsoft. He is on Twitter at @ericlippert and writes a blog about programming language design and other fabulous adventures in coding at http://ericlippert.com.
Join 3.1 million developers at
What You'll Learn
- Identify key flaws in System.Random (seeding, thread safety, exclusive ranges) that cause buggy outcomes
- Implement thread-safe and cryptographically secure random integers and doubles in C#
- Design continuous distributions using an IDistribution interface and visualize samples with histograms
- Build discrete distributions (uniform, weighted, Bernoulli, singleton) over values and C# objects
- Implement efficient weighted sampling via CDF+binary search, rejection sampling, and the alias method
- Apply Bayesian inference with priors and likelihoods to compute marginal and posterior probabilities in C#
- Estimate expected values using importance sampling and helper distributions for continuous weighted functions
Learning Roadmap
1.
Introduction to System.Random in C#
Introduction to System.Random in C#
2.
Introduction to Fixing Random
Introduction to Fixing Random
3.
Fixing Random - Discrete Distribution
Fixing Random - Discrete Distribution
22 Lessons
22 Lessons
4.
Fixing Random - Continuous Distribution
Fixing Random - Continuous Distribution
13 Lessons
13 Lessons
5.
Conclusion
Conclusion
2 Lessons
2 Lessons
6.
Appendix
Appendix
2 Lessons
2 Lessons
Eric Lippert
Eric Lippert is a programming language designer, blogger, author and editor of programming books. See his fabulous adventures at ericlippert.com
Trusted by 3.1 million developers working at companies
Anthony Walker
@_webarchitect_
Evan Dunbar
ML Engineer
Software Developer
Carlos Matias La Borde
Souvik Kundu
Front-end Developer
Vinay Krishnaiah
Software Developer
Built for 10x Developers











