If I made a program, and I wanted a random number.
I know it's not compleatly possible, since it takes numbers out of the ram.
Although there must be worse and better ways to do this.
What are the better ways do do it.

I love this topic. Random number generation is not only well discussed but then you have dozens of different kinds of random.

Are you aware of TRNGs and PRNGs?
https://en.wikipedia.org/wiki/List_of_random_number_generators

One of my tasks long ago involved a Gaussian random number generator. Some may call that OTR (other than random) and here's why it was needed. In production the spread was Gaussian so to simulate what would happen in real life, this was part of the simulation.

There are many fine off the shelf generators on the web, why do you need to create another?
Also, you have to define what efficient is. That can be the number of machine cycles or a statisical "correctness." You didn't say!

I love this topic.

I love this topic too. What I DON'T understand is why srand(time(NULL)) and rand, which is what we're all taught to use, are such lousy random number generators and you have to look elsewhere if you want decent random numbers. It's an interesting topic, but so many applications need good random numbers that I would have thought that some really, really smart people would study the issue (and they have) and simply provide the rest of us a nice simple standard way of doing it where we didn't have to research it ourselves and find one of the many "off the shelf generators on the web". I don't have to do that with vectors. I simply #include <vector>. If I'm not happy with the implementation, I can go find someone else's, but I'm provided with a standard one that works well. With random numbers, I'm not.

@AssertNull. I hear you.

And partly because asking for random alone is just the beginning of the question, no one has a simple one size fits all answer. That is, the random generators I've used have been picked by looking at the specification of the app we are creating. I supplied that Gaussein as an example.

Since I know there are many definations of random, that's why there's no good answer yet. The OP needs to reveal a lot more. Especially what "efficient" means to them. Again, one time it's CPU cycles, the next time it's the random number distribution and another time it's something else altogether.

What I DON'T understand is why srand(time(NULL)) and rand, which is what we're all taught to use, are such lousy random number generators

Probably for the same reason gets and atoi are so lousy. The interface was simple, they were "good enough" at the time, and time/experience changes what's considered acceptable in a library.

With random numbers, I'm not.

#include <random> is a move in the right direction, though I'd argue it's not "simple" due to a wide range of needs from an RNG and a bit of design by committee.

I helped a guy create a random number generator that kept track of keypress and mouse move/click times and some other "sorta kinda mostly might as well be random" stuff. He was gonna keep going with the project and do a bunch of statistical tests to see if it was truly random, publish a peer-reviewed paper, etc., etc., then his girlfriend stepped in and gave him the "I'm leaving you if you don't stop spending all of your free time on this stupid random number generator project" ultimatum. He had to think about it for longer than she probably would have liked, but eventually he picked her and very possibly the world of random number generation is the worse for it.

I predict this forum will now get a whole bunch of threads from 15-year-olds purportedly working on random generator projects and when you ask them for details and bring up your Gaussian example, they'll respond, "Yeah, I actually have the Gaussian part working, I'm just having problems installing the global keyboard hook so that no one can detect it".

Comments
1. Smart guy. 2. I see what you did there.

include <random> is a move in the right direction

Cool. Didn't even realize this was out there. I have to get familiar with the newer stuff. Thanks.

Comments
I think I should note the old way next.
The article starter is a financial contributor. Sponsored articles offer a bounty for quality replies.