HomeCoursesFixing Random: Techniques in C#
AI-powered learning
Save

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.

44 Lessons
20h
Updated this week
Join 2.9 million developers at
Join 2.9 million developers at
LEARNING OBJECTIVES
  • 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

44 Lessons

1.

Introduction to System.Random in C#

Introduction to System.Random in C#

Get familiar with System.Random's limitations and its impact on C# programming.

2.

Introduction to Fixing Random

Introduction to Fixing Random

Look at improvements to C#’s randomness, probability distributions, and sampling techniques.

3.

Fixing Random - Discrete Distribution

Fixing Random - Discrete Distribution

22 Lessons

22 Lessons

Master the steps to implement and optimize discrete distributions in C#, including Bernoulli and alias methods.

4.

Fixing Random - Continuous Distribution

Fixing Random - Continuous Distribution

13 Lessons

13 Lessons

Apply your skills to sampling and estimating expected values in continuous distributions.

5.

Conclusion

Conclusion

2 Lessons

2 Lessons

Explore probabilistic programming, improved tools, and efficient techniques for estimating values.

6.

Appendix

Appendix

2 Lessons

2 Lessons

See how it works to define and generate non-uniform random data in C#.
Certificate of Completion
Showcase your accomplishment by sharing your certificate of completion.
Author NameFixing Random: Techniques inC#
Developed by MAANG Engineers
ABOUT THIS COURSE
There are a lot of problems we face in programming that deal with uncertainty, statistics, and probabilities. Unfortunately, the majority of the general-purpose languages that we use on a daily basis don’t provide a great approach to solving them. This is particularly the case in C# with the System.Random class. The implementations of this class have been pretty poor for some time. System.Random in C# regularly leads to unexpected, buggy outcomes. If you’re a C# fan who’s looking for new ways to use the language, then this course is for you. It proposes different approaches to improving the System.Random class, providing a number of powerful techniques that solve problems more efficiently and with fewer lines of code.
ABOUT THE AUTHOR

Eric Lippert

Eric Lippert is a programming language designer, blogger, author and editor of programming books. See his fabulous adventures at ericlippert.com

Learn more about Eric

Trusted by 2.9 million developers working at companies

These are high-quality courses. Trust me the price is worth it for the content quality. Educative came at the right time in my career. I'm understanding topics better than with any book or online video tutorial I've done. Truly made for developers. Thanks

A

Anthony Walker

@_webarchitect_

Just finished my first full #ML course: Machine learning for Software Engineers from Educative, Inc. ... Highly recommend!

E

Evan Dunbar

ML Engineer

You guys are the gold standard of crash-courses... Narrow enough that it doesn't need years of study or a full blown book to get the gist, but broad enough that an afternoon of Googling doesn't cut it.

S

Software Developer

Carlos Matias La Borde

I spend my days and nights on Educative. It is indispensable. It is such a unique and reader-friendly site

S

Souvik Kundu

Front-end Developer

Your courses are simply awesome, the depth they go into and the breadth of coverage is so good that I don't have to refer to 10 different websites looking for interview topics and content.

V

Vinay Krishnaiah

Software Developer

Built for 10x Developers

No Passive Learning
Learn by building with project-based lessons and in-browser code editor
Learn by Doing
Personalized Roadmaps
The platform adapts to your strengths & skills gaps as you go
Learn by Doing
Future-proof Your Career
Get hands-on with in-demand skills
Learn by Doing
AI Code Mentor
Write better code with AI feedback, smart debugging, and "Ask AI"
Learn by Doing
Learn by Doing
MAANG+ Interview Prep
AI Mock Interviews simulate every technical loop at top companies
Learn by Doing

Free Resources

FOR TEAMS

Interested in this course for your business or team?

Unlock this course (and 1,000+ more) for your entire org with DevPath