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?
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
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
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".
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.
Regarding using tables to generate random numbers, one must be careful not to assume uniformity of probability (not saying there was a problem in this particular video) where there isn't uniformity. In fact, near-uniformity of digits where there shouldn't be is a red flag in code-breaking and auditing.
Isn't it about time forums rewarded their contributors?
Contribute to this discussion and earn rewards points that can be cashed out for dollars.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Hi. so this is actually a continuation from another question of mineHere but i was advised to start a new thread as the original question was already answered.
This is the result of previous question answered :
code for the listbox - datagridview interaction
At the top of the code ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.
Private Sub btn_addline_Click(ByVal ...