Most voted "random" questions
Use this tag for questions pertaining to random or pseudo-random numbers.
Learn more…236 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…
-
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 }
-
15
votes5
answers106673
viewsHow to generate random numbers in Python?
I would like to know how to generate random numbers in Python. I’m with version 3.4.
-
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…
-
11
votes4
answers2950
viewsDraw where the name cannot be drawn more than once
I need to make a simple drawing software, but I don’t know how to take the names that were entered in the list box and draw one among them. The same name cannot be drawn more than once. How to do…
-
11
votes3
answers31819
viewsRandom number range in C
In a certain program, I need to generate a random value greater than 1000 (with a limit set by me to up to 5000 (maybe it’s still too high)). This unique code refers to a type of registration to be…
-
8
votes1
answer2080
viewsRandom() generating repeated numbers
I am developing a small application to perform XML import, which searches the items present in the note and performs the search for them in DB company. When the item is not found, the link is done…
-
8
votes1
answer7864
viewsFunction to generate random alphanumeric characters
I need a C# function that manages a String of random alphabetic and numerical characters of size N.
-
8
votes3
answers1585
viewsHow to generate large random numbers in C++?
I’m looking to make a random number generator of [0.4], including these, only the problem is my teacher indicated that I used 4 million to generate random numbers and what value surpasses RAND_MAX ,…
-
7
votes4
answers4670
viewsSelect string at random
I need a way to randomly create a string between some options. Let’s say I have the strings "A" "B" and "C", it would be possible for Java to choose randomly?
-
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
votes1
answer177
viewsCreate a program that draws 6 numbers and shows how many times it was drawn
I’m making a program that draws 6 numbers (1 to 6) 1 million times and in the end shows how many times was drawn, but I have a doubt in the code, I’m optimizing in vectors not to use if, but in the…
-
6
votes1
answer156
viewsError while using Random
I set a random number to fill a fictitious table and did so: foreach (var usuario in LstUsuarios) { htmlUsuarios.AppendLine("<tr>"); htmlUsuarios.AppendLine("<td>" + usuario.Nome +…
-
6
votes4
answers3435
views -
6
votes1
answer270
views -
6
votes2
answers533
viewsMysql BD random record preventing consecutive equal records
I have a database where I want to pick up a random record. I can do this perfectly with: $query = "SELECT * FROM `mytable` ORDER BY RAND() The problem is that the database contains the entry order…
-
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…
-
6
votes3
answers3711
viewsHow to shuffle characters from a Java string randomly?
I’m developing a password generator program. In it the user can set the percentage of numbers, letters and special characters that he wants to have in his password, as well as the size of his…
-
6
votes1
answer430
viewsRandom always returning the same number
I have a method that its function is to return 25 random numbers on a list: static List<int> criarList() { List<int> lista = new List<int>(); for (int i = 0; i < 25; i++) {…
-
6
votes3
answers957
viewsRandom numbers are always the same
Why is this code always displaying the same random number results of a given? // Figura 6.9: fig06_09.cpp // Lança um dado de seis lados 6.000.000 de vezes. #include <iostream> using…
-
5
votes4
answers4937
viewsGenerate string securely random in PHP
How, using the PHP language, generate a string, preferably with configurable size, random enough to be used in routines dealing with cryptography and that for safety reasons cannot be insufficiently…
-
5
votes7
answers762
viewsRandomize results with PHP
I have such a structure (which I created): <div class="banners"> <?php echo do_shortcode("meubanner_1")?> <?php echo do_shortcode("meubanner_2")?> <?php echo…
-
5
votes1
answer136
viewsGenerate a random value in a range, excluding a range
Using Javascript how to make an interval with random values with an internal interval deleted? Exemplifying: min | | | | |x|x|x|x|x|x| | | | | max | | = accepted value |x| = denied value Code used:…
-
5
votes3
answers394
viewsWhat does it mean to assign Math.Random() > 0.5 to a variable?
What does that mean Math.random() > 0.5; in a boolean? Here is an example: class Pro { public static void main(String[] args) { int numero = 10; boolean[] array = new boolean[numero]; for(int i=…
-
5
votes4
answers6903
viewsGenerate random numbers that do not repeat
How can I generate a large sequence of random numbers that do not repeat? I have to generate 10,000 numbers from 1 to 1 million and store them in a file and they can’t repeat themselves. However…
-
5
votes2
answers101
viewsHow to get an item from a list randomly?
Suppose I have the following list: frutas = ['abacate', 'mamão', 'laranja', 'uva', 'pêra'] I need to capture one of these elements from list randomly. How would I do it in Python?…
-
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
votes2
answers1079
viewsHow to do a random query in Mysql without repeating data?
I’m creating a site type images type Pinterest that, in addition to other things, need to combine the following features: Infinite Scrool (I’m applying this code here:…
-
5
votes2
answers143
viewsRandom Hoice and shuffle with different behaviors
I’m testing some codes with the module random and I noticed a difference in behavior between random.choice() and random.shuffle(). Following the codes I’m training: import random alunos =…
-
4
votes4
answers313
viewsChanging a random string of characters using Stringbuilder
I have the following variables:: String mascara = "12****3*59**100*"; String numero = "12345768" There is a way to replace the asterisks of my variable mask by the values of my variable number?…
-
4
votes1
answer222
viewsHow to generate a random number within a range?
Using the mercy of arc4random_uniform(), how should I set the logic to generate a Random within a certain range? For example, given the range [5, 10] Candidates for Andom: 5, 6, 7, 8, 9, 10…
-
4
votes2
answers367
viewsRegex in dynamic string X characters, in dynamic content
Next, I have a page that generates a shuffled content with dynamic and non-dynamic strings, I need to take a dynamic value between separators |, it contains random data/strings around, which change…
-
4
votes1
answer3297
viewsGenerate random numbers in Java
How to generate only numbers larger than 2? How to generate only numbers larger than 2 and the generated numbers have to be multiples of 3(eg. 3, 6, 9)? How to generate only numbers smaller than 10?…
-
4
votes1
answer657
viewsRandomized and ascending order query in MYSQL
I have a table where I have the student’s name and his score, I need to pick up 5 random students and display them in ascending order of the score. I tried to do it this way, but he’s just randomly…
-
4
votes1
answer1307
viewsRename all files in a folder to random names
I need a command to rename all the files in a folder to a random name, which keep the same file extension and preferably with numbers, what I got so far was this: forfiles /P c:\teste\ /c "cmd /c…
-
4
votes1
answer78
viewsSingle ring value
I’ve seen several posts on the subject but it’s not exactly what I was looking for. A while ago when I was in internship, I was told to keep some records with a unique id on each one, and they told…
-
4
votes2
answers1071
viewsGuess a number, and in attempts, by the percentage show hints
I am trying to create a game in which the user must determine an interval and guess a random number that is generated within this range. When the user inserts a number to guess, the program must…
-
4
votes1
answer2155
viewsRead values from a table in Sqlite
I am in need of a help in the following situation: I need to take the values of a column in the bank and write these values in a variable, and then this variable will randomly generate one of these…
-
4
votes4
answers2266
viewsHow to generate random numbers for Draw?
I need to generate numbers for a promotion, these numbers should go from 0 to 99999. How can I distribute these numbers randomly and fairly, without repeating numbers already distributed?…
-
4
votes2
answers2957
viewsI need a new Random number for each line in an sql(server) query
I use the sql server. I need to use a Random number in several different columns (the same Random number) but I want a new Random number for each row... for example, let’s assume that TABELAX has…
-
4
votes1
answer153
viewsImages are repeating in Imageviews
I have 54 images need to show only 8, but have to have a random selection and can not repeat, I am programming on the platform of Android Studio. I use this code it works smoothly, shows the results…
-
4
votes4
answers874
viewsManipulating JS odds when using Math.Random()?
When using this function Math.floor((Math.random() * 10) + 1) I get a random number from 1 to 10. We assume that each number has a 10% chance so we have a 50% chance for Odd or Even, but if I wanted…
-
4
votes2
answers78
viewsDynamic/stochastic object allocation in QML
I am currently trying to do the following in QML, simultaneously: do dynamic loading of Objects previously created a separate file; by doing what is described above, select objects stochastically…
-
4
votes1
answer379
viewsFirebase: How to load random data into a Recyclerview?
I am using a Query to load only 6 items from the Firebase database in Recyclerview but so far I can only sort using the orderByChild, limitToFirst or last. Everything is working fine but... I want…
-
4
votes1
answer392
viewsRandomly select lines
I am developing a very complex system, where, in some cases I need to select only a few fields, a friend who has more experience in the area gave me some tips, but he did not explain why. I have the…
-
4
votes2
answers909
viewsGenerate float values between -1 and 1
I’m trying to generate values float between -1 and 1 to test if these are within the defined limits to create a vector with the amount of data that only means that I am only able to generate values…
-
4
votes2
answers584
viewsHow do I draw random names from each list without repeating them
I want to draw random names from 3 different lists, I have a program in Python that does more or less that. The problem is that they keep repeating several names in different combinations, I would…
-
4
votes1
answer166
viewsMath.Running defining minimum and maximum values other than 0
I’m trying to set the minimum and maximum value, using Math.random() * (max - min) + min;, for example, informing on the Html page the minimum = 10 and the maximum = 20, but the results are always…
-
4
votes3
answers77
viewsGenerate multiple different arrays containing random numbers
I am developing a program and need to generate an array of 16 elements, in which each input is 0, 1 or 2; and then I need to check if this array meets certain conditions. To generate this array, I…