Linked Questions

-2 votes
1 answer
951 views

I want to create some specific random, such that from 10 to 20. rand()%20; is create from 0 to 19
MrBoolean's user avatar
191 votes
14 answers
345k views

I need a function which would generate a random integer in a given range (including boundary values). I don't have unreasonable quality/randomness requirements; I have four requirements: I need it to ...
Matěj Zábský's user avatar
42 votes
4 answers
271k views

Possible Duplicate: Generating random integer from a range I am trying to create a program where the computer guesses a number the user has in his/her mind. The only user input required is whether ...
Jammin's user avatar
  • 433
16 votes
7 answers
19k views

Usage of rand() is usually frowned upon despite using a seed via srand(). Why would that be the case? What better alternatives are available?
Uncertainly Certain's user avatar
12 votes
4 answers
29k views

I've written a C function that I think selects integers from a uniform distribution with range [rangeLow, rangeHigh], inclusive. This isn't homework--I'm just using this in some embedded systems ...
solvingPuzzles's user avatar
20 votes
4 answers
9k views

One common way of choosing a random number in [0, n) is to take the result of rand() modulo n: rand() % n. However, even if the results returned by the available rand() implementation are fully ...
dragonroot's user avatar
  • 5,911
16 votes
5 answers
2k views

I have a stream of (uniform) random bits from which I'd like to generate random integers uniformly in the range [0,n] without wasting bits. (I'm considering bits wasted which are in excess of floor(...
uckelman's user avatar
  • 26.5k
2 votes
2 answers
6k views

I had an assignment that required us to generate a three digit number twice so a student can add them together and then check their work. I am still very, very new to C++ and my class regretfully ...
Chris 's user avatar
  • 21
4 votes
2 answers
2k views

Because of the pigeon hole principle, you can't just use output = min + (rand() % (int)(max - min + 1)) to generate an unbiased, uniform, result. This answer to a similar question provides one ...
Eoin's user avatar
  • 1,839
1 vote
3 answers
3k views

I am wanting to create a dice roller so that the user can choose a number of sides on a dice and it will randomise the response, My current code chucks out the same number all of the time. Sub ...
ipro_ultra's user avatar
4 votes
2 answers
1k views

Assuming I can generate random bytes of data, how can I use that to choose an element out of an array of n elements? If I have 256 elements I can generate 1 byte of entropy (8 bits), and then use ...
mpen's user avatar
  • 285k
3 votes
1 answer
372 views

This is not a duplicate of #11766794 “What is the optimal algorithm for generating an unbiased random integer within a range?”. Both its top-upvoted answer and its Accepted answer have to do with ...
JamesTheAwesomeDude's user avatar
0 votes
2 answers
422 views

I wrote a code which shows a question and 4 answers, ask to choose the correct one, and checks the choice. Now I would build a table which would contain 6 columns: question/a/b/c/d/correct_answer, and ...
Mac's user avatar
  • 1
2 votes
2 answers
162 views

I am developing a gaming platform that is subject to heavy regulatory scrutiny. I chose Math.NET because it seemed like a good fit. However I have just received this comment back from our auditors. ...
IntoNET's user avatar
  • 534
-2 votes
2 answers
92 views

I have to write a c++ program and have a problem only with the following part: [...] for that purpose, you will need two random integral numbers from uniform distribution on the set {0,1,...,9} (...
Jan Gąser's user avatar

15 30 50 per page