Most voted "randomnumbers" questions
Use this tag for questions pertaining to random or pseudorandom numbers.
Learn more…49 questions
Sort by count of

174
votes6
answers5796
viewsHow is computer randomization generated?
Doubts How computer randomization is done? What algorithm or mathematical basis does the computer use to generate those numbers? For example: No Javascript utilizo o Math.random() it returns me…

26
votes3
answers568
viewsCompute secure data randomly
Random functions are not entirely random in computation. I wonder if there is a safe way to generate a salt, or any other random string safely, without using external hardware. Can randomization be…

22
votes4
answers2442
viewsIn PHP how to calculate a random number?
How to calculate a random integer between 1 and 2000 using PHP, to make a draw? function random() { // codigo }

16
votes5
answers17254
viewsGenerate multiple random numbers without repetition
I’ve made some attempts to make a function that returns random numbers that don’t repeat themselves, I’ve made some attempts but none have succeeded, if you can show me a function that does that…

15
votes2
answers6108
viewsRandom draw, but with different odds
I am implementing a system where the user clicks on a button and a draw with balls of different colors occurs, but for each color there is a probability: He has a 30% chance of catching a blue ball…

14
votes5
answers2700
viewsDrawing strings from a weight array
My question is the following, I have an array with all the cities of the country,+ 5000 cities, I have a function that draws one of these cities and prints the result on the screen. I wish that the…

13
votes4
answers3372
viewsGenerate random numbers that result in a fixed sum
I need to generate random values for the inputs text of my table (remembering that it can have N lines), my code today can generate the numbers but I need the generated number to be at most X so…

12
votes1
answer605
viewsWhat is required to achieve maximum entropy?
I’ve been studying a little bit about random numbers and hashes, Yet something somehow still confuses me. In several groups related to cryptography I read about people talking about the addiction of…

8
votes2
answers141
viewsWhat is the difference between the functions Rand, mt_rand, random_int?
To generate random numbers with PHP, there are some functions. Among them rand, and mt_rand. Until recently, I used the mt_rand, 'cause as the documentation says, she’s a "improved random number…

7
votes1
answer473
viewsHow to generate correlated variables in R?
I managed to create the uniform variables X and W, both with normal distribution, using the formula rnorm in the R. However, I wanted to create variables so that they had a 0.8 correlation value.…

7
votes2
answers2142
viewsDifference between /dev/urandom and /dev/Random
I recently read a post on the oracle jdbc driver, talking about making the following configuration on jvm running on Linux: Djava.security.egd=file:/dev/../dev/urandom According to the reference,…

7
votes4
answers16556
viewsGenerate random numbers in Python without repeating
I have the following situation: I have a vector with 4 indexes. In each index a random value is generated from 0 to 100. I have a code that does this perfectly, but sometimes the numbers repeat.…

6
votes3
answers12748
viewsGenerate random numbers in an Array from 10 to 50
Since I can generate an array of random numbers with a limit, they should be numbers from 10 to 50. To generate random numbers from 0 to 50 I use: Random random = new Random(); int array[] = new…

5
votes2
answers1988
viewsA Good Fortran Random Number Generator
The GNA of FORTRAN (Rand()) seems to be bad, this because it is proved to be worse than very simple random number generators. For example, in my simulations the GNA below SUBROUTINE GNA(iiseed) USE…

5
votes1
answer1167
viewsHow to get a random number in Kotlin?
How can I get a random number between two values? Like ruby does with rand(0..n)

5
votes1
answer593
viewsHow does seed influence the generation of random numbers?
The doubt is very simple, I would like to know how the class System.Random generates random pseudorandomness numbers from a seed, which I find odd. I know they are not totally random, and so I have…

5
votes1
answer45
viewsRandomizing two sets of numbers, not repeating the values within each group (R)
Whereas I have these individuals on file: ID 1 1 1 3 3 3 7 7 7 And I need to assign two sets of numbers to ID randomly (set1  1,2,3; set2  5,15,25). To do this my attempt was: df %>%…

4
votes1
answer941
viewsHow to create invertible random matrices in R
One of the ways to find the estimator using the method of least ordinary squares is by generating random matrices, given by the formula: B = (X’ X)^1 X’Y Where Y = a+bx+cw+u, being x and w random…

4
votes1
answer666
viewsGenerate random number between 99 and 99
I’m having some difficulty here in my code which is the following, I know that to generate random numbers between 0 and 9 is  x = rand() % 10. So now I wanted to generate numbers between 99 and…

4
votes1
answer984
viewsWhat is Mersenne Twister?
PHP has a function called rand. There is also a function called mt_rand. I was studying about these functions and realized that, in previous versions, it was necessary to use such a "random number…
randomnumbersasked 8 years, 7 months ago Wallace Maxters 102,340 
3
votes2
answers2180
viewsGenerating a pseudorandom number based on an input
I need to generate a random number based on another input number, so that for the same input number, the function should always generate the same output number. For example, meuRand(4) would always…

3
votes1
answer149
viewsIncrease the reliability of random numbers
I have a function that generates pseudorandom numbers with rand who has a Seed which is a publicly known time. Change the Seed is not an option. The application needs a more accurate degree of…

3
votes1
answer191
viewsHow to get really random numbers with 'Rand()' in C?
For a schoolwork, I need to create a game, for which I need to generate a random number to make it fair. In one case, as I will post below, I need to assign a random number between 0 and 2 to modify…

3
votes1
answer592
viewsWhat is a random seed?
I asked a question here about a question I had about how we used random number generation. What is Mersenne Twister? There I quote that PHP uses a term called "sow random numbers" or "random seed".…
randomnumbersasked 8 years, 7 months ago Wallace Maxters 102,340 
3
votes0
answers69
viewsAlgorithmic predictability in random number generation
At the end of writing that one question, I realized that it was too wide. So I decided to break it into topics. There is a succinct way to observe the predictability of a random system? It would be…
randomnumbersasked 7 years, 4 months ago nmindz 2,978 
2
votes2
answers7781
viewsGenerate random number without repetition in C
Hello, I am making a memory game in c, and would like to know how to generate a random number without repetition. I will post what in the function so far. I will need to do another function only to…

2
votes1
answer12084
viewsRandom letters: How to generate with Rand and how to compare them in C
I’m trying to create a char vector of 10 positions, I want to feed it with 10 random letters and sort down with Bubble Sort. My question is: does Rand generate random characters as well as generate…

2
votes0
answers269
viewsGenerate random numbers in a vector of floats in the C language
I would like to know methods of generating a sequence of random numbers, ranging from 0 to 10, of type float in a size 10 vector.

2
votes1
answer216
viewsWhen I create a function in C++ do the variables within it stay in memory?
When I was studying pseudocode, I learned that when you call a function and create a variable, it only "exists" when I call that function, for example. funcao teste(): x = 10 retorna x In case, when…

1
votes2
answers114
viewschohan bakuchi in basic C
I am having a doubt in the program I made to represent the game chohan bakuchi, this game has as a rule to roll two dice of 6 sides in a cup before to show the dice if it makes the bet in which the…

1
votes1
answer133
viewsRandom ads with view counter
I’m with the following script to put random ads on the site, besides simple and easy also works really well and fast with various ads. The problem is this: How many times each ad was chosen by this…

1
votes0
answers66
viewsGenerate pseudorandom numbers
Featuring a pseudorandom number generator that generates a sequence of numbers X1, x2, ... in the range [0,1]. How to turn these numbers into Y1, Y2 numbers... in the range [11, 17]?

1
votes1
answer85
viewsHow to create a good GCL to do Random function?
I know it’s rediscovering the wheel, but I want to know how I can implement in my own way a nice linear congruent generator to draw integer numbers from 0 to 2^B1. How to choose constants, how many…

1
votes1
answer40
viewsFast even random float within range
I did the following lcg (linear congruency generator) to draw unsigned int from 0x00000000 to 0xFFFFFFFF uniformly. Just for testing, I used the seed equal to zero and raffling the first five…

0
votes2
answers112
viewsWhat’s wrong with my Quicksort code in C?
Here is my code: #include <stdio.h> #include <stdlib.h> int lista[1000]; int tamanho; main () { printf("Tamanho: "); scanf("%d", & tamanho); int c; for (c = 0; c < tamanho; c++) {…

0
votes2
answers774
viewsHow to randomize an Array in c++
There is a lot of material here about arrays ordering methods (quicksort, bubblesort, etc.) but I wanted to know if there is a "clutter" method of arrays, i.e., shuffling the elements of an array.…

0
votes1
answer66
viewsHow to select by the bank the value of the column using the Random() method
I made a project on Android that is a little hangman game, where I can record in the Sqlite database the word and a hint. In my Databasehelper class I created the normal database, and made some…

0
votes1
answer2628
viewsHow to generate random numbers but with some restrictions in python?
import random v=[1,7,15] x=random.choice(v) How do I generate more numbers "1" than "15"? At 10000 times, choose 1 number and at the end: number 1 must have left about 40%. number 7 must have left…

0
votes0
answers92
viewsHow to return the same random number in different systems?
A pseudorandom number generator like the rand() of PHP and the new Random.Next() of . NET will return different values same using the same seed and even full range, and this is not the right way…

0
votes1
answer684
viewsRandint does not generate random numbers the second time I use it
My randint when used the second time it does not generate new random numbers, it remains with the same generated numbers. I know that in C when this happens I can use the srand(time(NULL)); , but in…

0
votes2
answers1240
viewsBy clicking the button to call function Avascript the sume button
I’m trying to make a code to generate random number in Avascript, put a button to call the function, call the function correctly, however I have to update the page to be able to view the button, I…

0
votes1
answer105
viewsCreating an object with a random internal datum (Random)
I am trying to create an object called "State", however I would like the DDD of each object, when creating, to be generated randomly. class Estado { public int Resultado { get; set; } public string…

0
votes2
answers814
viewsValidate CPF  C language
I need to generate a random and valid Cpf for a college job This is the code I’ve developed so far, it’s generating letters instead of numbers in the twodigit checkers #include <stdio.h>…

0
votes1
answer33
viewsProblem when trying to split an array of randomly ordered numbers into two equal parts using Godot/Gdscript
I am currently creating a game in Godot 3.2.3, and in this game I need to create an array that contains numbers from 1 to array.size() (example:[0,1,2,...,30]) and that such numbers are in random…

1
votes2
answers543
viewsHow to generate random numbers without rethinking in Java?
Something similar to the code below. Numbers in the Random range that do not repeat public void sorteiaCartelaB() { for (int i=0; i < b.length; i++) { b[i] = (int)(Math.random() * 60 + 1); for…

1
votes2
answers52
viewsI’m not finding the highest value in a list with random values
I need to find the highest value in a list of 50 random numbers. To generate these numbers, I used the functions sample and randint. So to generate the list I use: lista = [sample(range(0, 200),…

1
votes1
answer37
viewsHow to generate a random number only once? (Javascript)
Hello! I’m trying to create a "little game" where I get a random number between 1 and 100 and the user has to try to hit, if he kicks up, print an msg for him to try a lower number and vice versa.…

2
votes2
answers61
viewsRandom generation
Hello. I was asked a question in a random number study in C. How would I generate a value in an interval that is not continuous? Generate a value between 10 to 15 or 20 to 25, for example.

2
votes2
answers56
viewsI can’t find the highest value in a flipbook dictionary
I need to find the highest dictionary value using a function running with the 'for' loop I was able to find the values of all the other sets, except the dictionary values. To generate the dictionary…