Questions tagged [random]
This tag is for questions pertaining to random numbers, whether pseudo random or truly random.
807 questions
2votes
0answers
74views
backward induction algorithm computation
Is there a way to significantly speed-up this code? I'm solving a dynamic programming model using a backward induction algorithm. A crucial step is to calculate the current-period value function (VF), ...
2votes
1answer
91views
randi Template Function Implementation for Image in C++ (Rev.3)
This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++, rand Template Function Implementation for Image in C++, randi Template ...
5votes
1answer
253views
randi Template Function Implementation for Image in C++ (Rev.2)
This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++, rand Template Function Implementation for Image in C++ and randi Template ...
6votes
1answer
222views
randi Template Function Implementation for Image in C++
This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++ and rand Template Function Implementation for Image in C++. I implemented <...
5votes
6answers
2kviews
Bubble sort with 10 random numbers
I want to make a bubble sorting algorithm of 10 random (non-repeating) numbers from 0-50. I changed many aspects of it while making it and finally got it to work, but I would like to see if there's ...
4votes
3answers
105views
Number guessing game in Rust
I am learning Rust and would like a review to make sure I am following best Rust practices before continuing. The user enters a number between 1 and 100 up to 6 times to guess the randomly-generated ...
6votes
1answer
252views
A PCG-based random number generator that is interchangeable with System.Random
I took the basic structure from this link and wrote the following class. Can you review the code? Can you find a silent bug? ...
5votes
1answer
340views
rand Template Function Implementation for Image in C++
This is a follow-up question for An Updated Multi-dimensional Image Data Structure with Variadic Template Functions in C++. I am trying to mimic Matlab's rand function into TinyDIP library. The ...
5votes
1answer
109views
Generating random bytes
I implemented a simple function that generated random bytes Vec<u8> with given n size. Then I wondered how can I optimize ...
5votes
1answer
138views
Cryptographically secure random int in range
I tried to make a cryptographically secure random int in range generator for javascript, practically the javascript equivalent of php's random_int(min,max): ...
15votes
1answer
1kviews
Typical password generator in Python
Password generators are extremely popular on CodeReview with beginners to both coding in general and Python in particular, for a number of reasons: They're (seemingly) easy to implement They offer an ...
4votes
3answers
165views
Efficiently generate a random position inside an outer rectangle but outside an inner rectangle
It should be a uniform distribution (ie: every point is equally as likely). I also don't want to use the simple solution of: "in a loop check to see if the current generated point is within the ...
6votes
1answer
544views
Generate unique temporary file names in C++20
WARNING: do not use this solution See discussion in the accepted answer's comments. Basically, this solution would reproduce std::tmpnam's and ...
2votes
3answers
697views
Step-by-step re-arranging of a string with randomized characters
A sloppy code featuring algorithms to efficiently randomize the characters of a string "Hello C" and then print out in the console the re-arrangement process for every character. ...
5votes
1answer
87views
RandomNumber wrapper in Lua
This is a wrapper I wrote for math.random(). I have a larger program that will create a JSON file to 'load' from when I want to resume. However my program heavily ...