Questions tagged [random]
This tag is for questions pertaining to random numbers and their generators, whether pseudo-random or truly random.
35,242
questions
0
votes
0
answers
11
views
I cannot figure out why this isn't working on the random side
I am in a computer science 101 class and I'm attempting to create things based on what I have learned.
I created this very basic dungeons and dragons npc creator to allow for me to learn how to use ...
-1
votes
0
answers
36
views
Disable automatic re-seeding in OpenSSL random generation
I am using OpenSSL C++ random generation, more specifically the RAND_priv_bytes() function.
My goal is to make sure the random generator used in RAND_priv_bytes() is seeded by my custom function, and ...
0
votes
3
answers
76
views
Generating an array of random numbers with conditions
I have a list of length 64, such as first_list = [64, 27, 99, 133, 0, 41, ... ]. Numbers in this are some random selection from 0 to 150 (minimum value is 0 and maximum value is 149).
I want to ...
-1
votes
0
answers
24
views
Speeding up by removing col and row for-loops (Randomization with condition)
In a financial application that involves bootstrapped resampling, I'm aiming to optimize (vectorize) a function to eliminate the need for for-loops.
The setup. I have a dataset with multiple gvkeys (...
0
votes
0
answers
60
views
Deterministic pseudo-random numbers (or: getting Nth random number with a fixed seed) [closed]
I am trying to create a function r0(x,y,z) such that for every triple x,y,z r0 will produce the same pseudo-random number. Since all these arguments have a ceiling value, I can generate a seed S like: ...
0
votes
1
answer
41
views
How to generate uniform random numbers in Python close to the true mean and standard deviation? [closed]
I am trying to generate uniform random numbers as much as possible close to its theoretical definition, particularly in Python. (i.e., I am familiar with the concept of Pesudo-Random Generators (PRGs) ...
-4
votes
1
answer
43
views
how do i change this to be able to generate a random item from my list? [duplicate]
my list containing fruits
i'd like for the code to pick (At random) a fruit from my list and then display it.
the code works currently but doesn't have the random function i'd like for it to have.
...
2
votes
3
answers
53
views
Generating random dataframes (5 rows 9 cols) with each rowsum should be 9
I'm trying to create 10 or more of pseudo dataframes.
The data frame dim should be 9 columns with 5 rows(Mon, Tue,Wed, Thur, Fri), and each rowsum should be 9. like below.
Factor1 Factor2 ...
0
votes
0
answers
32
views
Encryption With Randomization Decryptor [closed]
A friend of mine wanted to create encryption using randomization, and I told him that was a bad idea. I wanted to create a file to prove him wrong, however, I noticed that the product that I came up ...
1
vote
1
answer
29
views
Wordcloud centralize and reduce overlap in randomly positioned words inside a plot
import plotly
import random
import plotly.graph_objects as go
from plotly.subplots import make_subplots
random.seed(42)
words = ['potato','hello','juvi']
colors = [plotly.colors....
-1
votes
0
answers
38
views
generate random number non repeating with threading [closed]
import random,time
from threading import Thread
usleep = lambda x: time.sleep(x/1000000.0)
def getcode(numbers):
data = '{"code":"'+ str(numbers) +'}'
print(data)
inputNumbers =...
0
votes
0
answers
17
views
Generate Random String Flutterflow
I'm new in Flutterflow and I'm a little confused on using 'Custom Code'. I want to create something that will generate random string. I don't know if this is in a category of Widget, Action, or ...
2
votes
1
answer
41
views
a fast way to generate true-false matrix based on random sampling with a matrix of probability values
I have a n × n matrix in which values are between [0,1] and each column has the same values.
These values represent probabilities for each element of the matrix to take the value TRUE or FALSE.
I am ...
1
vote
0
answers
31
views
How to implement a random natural motion for a single particle?
I have a Drone class implemented as a Thread that is called from a Map class and every X milliseconds the movement() function of the Drone class is called to update the position and show it on the map....
0
votes
2
answers
44
views
Stata Simple Randomization in One Line WITHOUT USING SPLITSAMPLE
I'd Like to create a simple randomization of a dataset. The goal is to have 500 in treatment and 500 in control. This question is about Stata efficiency: I want to do it in one line.
I can do it in ...
-1
votes
0
answers
16
views
Terraform: Help understanding reading a value from random provide with a r keepers resource
The Terraform docs for random have this example:
resource "random_id" "server" {
keepers = {
# Generate a new id each time we switch to a new AMI id
ami_id = var.ami_id
...
0
votes
0
answers
10
views
How does HD wallet generates the ENT? [closed]
i've been searching for a while but i didn't get a decent answer, I'm working on a persona project and i would like to ricreare as precise as i can a real HD wallet
does anyone know how are ENT ...
-2
votes
1
answer
65
views
Getting a random position fixed distance from a point
I am trying to develop a solar system simulation.
To initialise the display, I need the planets to be randomly placed in their orbitals (fixed orbital radius) from the Sun. How do I get the random ...
-2
votes
2
answers
80
views
How to constantly generate random numbers inside for i in range loop
import random
world_size=8
for i in range(world_size)
chunk_type=random.randint(1,2)
print(chunk_type)
import random
class chunk_type():
chunk_type=random.randint(1,2)
world_size=8
...
1
vote
2
answers
49
views
Random number between two numbers with "gaps"
I am trying to generate random numbers between two values.
I am using, vba for this, so that, the way to do It would be:
Int((upperbound - lowerbound + 1) * Rnd + lowerbound)
But because of the ...
0
votes
1
answer
57
views
Math.random won't compile in jGrasp
When I try to use the Math.random in a code I get "error: Cannot find symbol" and points to the "." between Math and random. However when I rewrite the code into an online ...
-3
votes
3
answers
57
views
How do I create a random number generator, that each time it is called upon, returns a different value?
I've been trying to do this so I can create a maths problem game, with all random numbers so the game can continue for aslong as the user would like to. However I am currently using this:
Dim rand As ...
0
votes
2
answers
50
views
How can I use random string in cypress test
How can I use random string in my cypress test so that whenever my gitlab-runner runs the code, the system will use difference strings like the Email and Phone number majorly.
I have my class created ...
-2
votes
0
answers
16
views
Compare a random generated list (list 2) with another list (list 1) and print the value from list 2 and the corresponding index in list 1
These are the instructions for the problem:
Use a for loop and a random integer generator to generate 5 random integers in the range specified by the user in step a. Check if each number is in the ...
-2
votes
1
answer
30
views
Select with random ORDER in MySQL Within 1 row [closed]
I Have this Level 1 table
enter image description here
I want to make query, when the query is execute the order of J1,J2.. J5 is in random order
I have this query
SELECT j1,j2,j3,j4,j5 FROM `level_1` ...
-3
votes
1
answer
119
views
How to randomly distribute mines for a Minesweeper program
I've gotten up to Test 9/10 of the autochecker and have made my programming now 333 lines of Java code, as per the course requirement (being written in Java, not over XXX amount of lines). Basically, ...
0
votes
2
answers
55
views
How to randomly change order of an array on click in React
I am trying to write a simple dice game in React, which randomizes the order of players before play begins.
I am trying to use a function for shuffling arrays which has worked in a vanilla JavaScript ...
0
votes
3
answers
57
views
Cannot find solution to a randomly generated equation
im fairly new to python. trying to create a math quiz game as an assignment. i tried saving random int to a variable but that would return same value. i switched to creating a function, now im able to ...
1
vote
2
answers
60
views
Is xoshiro128** pseudorandom number generator reversible?
This answer mentions the xoshiro128** algorithm and provides a JavaScript implementation.
Question: Is it possible to derive the seed if you know the first random number produced by this generator?
2
votes
1
answer
66
views
Why is Random() not behaving as expected? [duplicate]
I've been scratching my head over this for long enough, It's time for the big guns:
System.out.println(new Random(10).nextInt());
why does the above seem to print -1157793070, always?
2
votes
1
answer
26
views
Create samples from trapezoidal probability density function
I have defined my probability density function as follows:
def trapezoidal_pdf(x, a, b, c, d):
const = (2 / (d + c - a - b))
if a <= x < b:
probability = const * (x - a) / (...
0
votes
2
answers
29
views
I Run set /A Prov=%RANDOM% * 6 / 32768 and get the same number (5), every, single, time
Running this line of code in a .bat file with delayed Expansion enabled.
I've tried:
set /A Prov=!RANDOM! * 6 / 32768 (Always Equals 5)
I've tried:
set /A Prov=!RANDOM! * 5 / 32768 (Always Equals 4)
...
0
votes
1
answer
38
views
AutoHotkey Code for Randomly generating number not working anymore
The following code presses the cursor every few seconds.
When I first made it, it just pressed the cursor every 5 seconds, but the game realised what I was doing.
So I changed the code, with the help ...
-3
votes
0
answers
22
views
I created an object of Randon class in java , But when invoking nextInt() method using the object it's giving cannot find symbol error [duplicate]
java.util.Random ran = new java.util.Random();
int target_number = ran.nexInt(10);
D:\CODING\JAVA\JAVA FILES>javac Gamelauncher.java
Gamelauncher.java:21: error: cannot find symbol
...
3
votes
1
answer
56
views
Recreate randperm Matlab function in Python
I have searched on stackoverflow for people facing similar issues and this topic Replicating MATLAB's `randperm` in NumPy is the most similar.
However, although it is possible to recreate the ...
0
votes
1
answer
23
views
mixing of noise from four corner glsl
I am studying noise from the bookofshaders and in 2d noise this is the code in the book or website.
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
...
0
votes
1
answer
56
views
RNG Challenge Python
I am trying to solve a CTF challenge in which the goal is to guess the generated number. Since the number is huge and you only have 10 attempts per number, I don't think you can apply binary search or ...
1
vote
1
answer
38
views
python random.choices() not giving equal number of elements even if we give equal weights
I want to create a random list with diffrent combinations of elements in the list. The count of each element appearing in the final list should same.
For example
>>> set_sizes = [0, 3, 6, 12]
...
0
votes
0
answers
23
views
Repeatedly using randperm until a standard is met always gives duplicate results on two consecutive runs
We have in Matlab the magic function, which generates a magic square. However, it always gives the same square while there can be multiple possible magic squares for a given dimension.
Now, I want to ...
1
vote
1
answer
75
views
Random integer generation performance optimization
I am looking to generate random integers on the interval [0, n) as fast as possible:
from random import Random
rand = Random(123)
def rand_func(max: int, random: Random):
return int(random....
-1
votes
1
answer
25
views
How to generate random double with RandomNumberGenerator in .NET 6
In .NET 6, as RNGCryptoServiceProvider has been marked as obsolete in .NET, I'm trying to find an alternative to generate evenly distributed random doubles (between 0 inclusive and 1 exclusive). I ...
0
votes
1
answer
28
views
getting random sampling from cartesian product
Consider the complex number z = x+iy. I have an object constructor class that can take a complex number and plot something from it, say pole(x,y).
I want to construct an array that considers all the ...
0
votes
1
answer
55
views
AutoHotKey, pick a random word from an array from a text file in a folder
I need help writing an application.
I have different arrays in text files and I would like one word to be randomly selected from them.
animals.txt
For example
[
‘cat’,
‘dog’,
‘horse’
]
and
furits.txt
[...
0
votes
1
answer
91
views
RDRAND intrinsics on apple silicon - How to generate a random number in c++?
How would you create a random number based on RDRAND ARM64 intrinsics on apple silicon (M1+) ?
Since arm-v8.5-A RDRAND is supported, but how can you use it on a m1 machine?
-1
votes
1
answer
37
views
How can I shuffle data in csv file?
I have the following dataFrame
The data is from csv file and I would like to shuffle in each rows
this is my code that I imported csv file
df = pd.read_csv('data1.csv',header=None, names=cols)
...
1
vote
0
answers
50
views
Take random sample from each column by group in R
I have a dataset with several thousand households and for each household the consumption of roughly 60 food items was recorded for one month of the year.
I want to generate annual food consumption for ...
1
vote
0
answers
48
views
uniform_real_distribution<float> is returning 1 [duplicate]
I've observed that a sample generated from a std::uniform_real_distribution<float> can be equal to 1 (compiled using Visual Studio 2022).
This is in contrast to the description in standard ...
0
votes
0
answers
30
views
Excel - semi-random ordered list from sample names
I have a list of employee names, and I want to extract a random pair without picking the same names too frequently. I was thinking of complex ways to add a weight metric that increases for each time a ...
-4
votes
0
answers
21
views
How do I append a dictionary with random prices from original starting point
Imagine I start with 5 stocks
dict1 = {'BA':57.0, 'QQQ':545.5, 'AAPL':150, 'SPX':245.5, 'JPM':150, }
how can I increase the dictionary to hold say 500 random prices for each asset from the original ...
0
votes
0
answers
30
views
How to display a random photo from the gallery without picking it in flutter?
I want to create a flutter app that shows me a random photo from the phone gallery, I don't want to choose it like with the image picker, I would like a button that loads me a random image.
I've tried ...