Questions tagged [random]
This tag is for questions pertaining to random numbers and their generators, whether pseudo-random or truly random.
34,003
questions
0
votes
1
answer
15
views
generate string of random letters and spaces in R
I am trying to generate random strings of words from randomly selected letters and compare their similarity to a string.
Using the random package, I can easily generate random sequences of letters of ...
-1
votes
0
answers
5
views
My randomizer variable is throwing errors when used as a value in a 2D array (Javascript) [duplicate]
New to coding. I'm making a generator that compiles random lines from Shakespeare's most famous sonnets to create a new sonnet. The issue is that finalArray throws an error only when I use randomIndex ...
0
votes
0
answers
8
views
AES-based pseudo random
I'm reading the paper "Concerto: A High Concurrency Key-Value Store with Integrity
".
For memory checking, they said they used AES-based pseudo random function, which has two input and ...
-2
votes
0
answers
14
views
cant detect int or str with if statement on an input [duplicate]
I made a random number generator where you had to guess the number that was generated. I was also trying to put a str/int detector where if the input was a string it would print an error message but ...
0
votes
0
answers
8
views
How to fix a random value in the rest of the codes?
I have multiple functions, the first one generates a random number, the others use the value of the first one. But I want to fix the return value of the first function and use it in the rest of my ...
0
votes
0
answers
18
views
SQLITE select random N rows in sql [duplicate]
I've got two tables which both have hundreds of millions of rows.
One is PAPER. Each row is unique with a column called "paper_id" as its key.
The other is PFOS. Each row has two columns, &...
0
votes
0
answers
16
views
SQLITE select random N rows
I've got two tables which both have hundreds of millions of rows.
One is PAPER. Each row is unique with a column called "paper_id" as its key.
The other is PFOS. Each row has two columns, &...
0
votes
0
answers
30
views
2D Array Random Path
I am developing a text based adventure game and I am implementing a small map feature. I am trying to make an algorithm that randomizes a map with results similar the the one below. However, I haven't ...
0
votes
0
answers
12
views
Generating Random Password with user defined length and from selected list of letters, numbers & symbols
I'm writing code for Random Password generator where users should have an ability to select the length of password from pre-defined range (15,25) and code will generate random password using letters, ...
-1
votes
0
answers
26
views
Randomly select 10% columns and make them as NA in R
I have a dataset with over 500 columns and 10 rows and I would like to iterate the following procedures 100 times:
Randomly pick 10% of the columns
Make this 10% coded as ./.
create per each ...
0
votes
0
answers
25
views
How to redefine a string and give it a randomized value from an array? [duplicate]
The code goes like this:
#include <iostream>
#include <random>
#include <cstdlib>
using namespace std;
int main() {
string taijutsu;
string ninjutsu;
string eyes;
...
0
votes
1
answer
67
views
How we take just two numbers in Perl using rand?
In Perl using rand can we exclude number between max and min except some number.
Max 3 Min 1
X = Int (rand(max - min + 1) + min )
Result will be 1 and 2 and 3
I want to except 2 how did it in Perl?
1
vote
0
answers
19
views
How can I choose a random turtle to move a random amount of steps?
Im making a turtle race where 5 different turtles are racing each other and they each take a random amount of steps. But how do I make it that it also chooses a random turtle to move a random number ...
0
votes
1
answer
16
views
Filling randomly form fields from a list
Is there any way in python to fill in the fields of a form (first name, last name) by taking them randomly from 2 pre-filled lists (name list and surname list)? And instead automatically randomise, ...
-2
votes
0
answers
39
views
Making the Appropriate method call? [closed]
So I'm not sure how to make the appropriate method call. I created all the following code below according to some of the stuff that I know and according to what I was asked for of the assignment. I ...
0
votes
0
answers
12
views
Random videos followed by selected videos from array
I've been making a site that plays 60 random videos (without duplicates) one after the other. However, I'd like it to play certain videos after a certain amount of videos have been played. Once the ...
-1
votes
2
answers
24
views
Can anyone explain that how to print max and min in the code
This is a code
random is used in the code
the query is to find max and min value of z
import random
x = random.randint(2,6)
y = random.randint(1,2)
z = x + y
print(z)
0
votes
0
answers
20
views
random variable over 2-mate sphere with radius 5 [closed]
So, I have generated pseudo random numbers sequence and now by using that sequance let's say x1, I have to generate uniformly distributed random variable(2-mate sphere with radius 5). How can I do ...
-5
votes
2
answers
53
views
How do I print different random numbers in for loop?
I am trying to generate random "credit card" form. But when I do for loop, then it prints the same random generated "credit card number" everytime.
Example:
Output looks like this:
...
-1
votes
2
answers
39
views
Is there a way to change the color of your website when refreshing it?
I have made a website with one specific theme, is there a way to change the color of the background/text of the website when you refresh it? here is some code which can only change the background. How ...
-1
votes
0
answers
29
views
Why is rand.Next() giving me duplicate values within a nested for loop? [closed]
public static void Main()
{
Random rand = new Random();
ArrayList arr = new ArrayList();
for (int i = 0; i < 5; i++)
{
ArrayList subarr = new ...
1
vote
2
answers
28
views
How to tune random.choice probability - python -
I made a function that randomly selects one from a list of texts.
def ttc(*arg):
a = random.choice([*arg])
return ''.join(a)
print(ttc("Price", "Condition", "Loan&...
-4
votes
0
answers
19
views
Receiving same output from Math.random() function in game I'm creating [closed]
If I console.log my generateOutcome() function I get a randomized output however every time I click on a door in my web game I'm trying to create I never get the monster ('you die') option...I'm sure ...
0
votes
1
answer
35
views
Random.Choice always the same result
Some pretext that's maybe useful idk. I use mixer and am trying to do a random music choice but the random.choice always take the last one (song 5). This is my code
if Mamp=='1':
vad=input("[1] ...
0
votes
1
answer
19
views
python 3 how to generate multiple random element in list for loops
I'm doing a coding exercise and it's to build a password generator. I understand I need to utilize the for loop with the list containing the elements but I'm having trouble getting multiple random ...
1
vote
4
answers
70
views
Generating a shuffled range in python
I need to generate (iterator) a random sequence of 32 bit integers with absolutely no repeats. The naive solutions to this problem don't work for me because of the massive sizes involved, for instance ...
0
votes
1
answer
25
views
Sampling with parameters in SAS
I have a large dataset dataset with 20 columns, and the columns "ltv", that contains the classification high, low and medium and "ticket" that contains values. I need 500 samples ...
0
votes
0
answers
14
views
Sampling without replacement along a 2D grid in Cython without gil (can be in C++)
I have essentially a 2D grid of N by M (i.e. N rows, and M columns). I would like to sample from this grid without replacement in Cython without requiring the GIL. I would want something like this
for ...
0
votes
3
answers
41
views
How to make random non-repeating numbers?
I made a code that could generate random numbers, but my issue is that sometimes it would repeat two or three numbers from time to time.
int winnum[] = new int[6];
System.out.print("Lotto ...
0
votes
0
answers
24
views
Assign new material slot and random colors to existing objects
I am trying since days to assign new materials and random colors to meshes that already exist in a Blender scene.
I need to do it in Python but I cannot find a solution.
I would like each mesh to have ...
-3
votes
0
answers
48
views
How to do Random assignments in python [closed]
I am new to python and looking for a simple solution to my problem.
I have examination papers to be reviewed by a group of teachers and I wanted to randomly assign the papers to a group of teachers by ...
-1
votes
0
answers
9
views
Show random DIV with refresh once a week?
we found a fiddle to show random DIVs by refreshing the Page.
This Code works fine, but now we want to edit this Code and we want that the DIVs will just refresh once a week. Is this possible?
<div ...
0
votes
0
answers
8
views
Is there a way to mock Random.Next regardless of what gets passed to it and where it gets called?
I have the following method I wish to unit test:
public class Board
{
public static BoardElement RandomElement(List<BoardElement> elements)
{
int index = Random.Next(elements....
0
votes
2
answers
23
views
random number generating function as argument in python
I want to pass a function which generates random normal numbers to another function, do some calculations and pass again the random function x times. At the end there should be a Dataframe with x ...
-2
votes
1
answer
48
views
Generating a random number that ends with a certain digit in Java
How does one generate a random number between 0 and 500 that ENDS WITH 5 in Java? I'm fairly new to programming.
1
vote
1
answer
39
views
Random array element creation into Dom only once JavaScript
I've got a problem to insert a random array element into the DOM. I want it to only do it once for each array element but the code keeps fetching the element infinitely.
I'm doing a card game and want ...
0
votes
1
answer
33
views
Randomness between Jupyter Kernel Restarts
Problem:
I am currently working on clustering of data and found a weird behavior in my Jupyter Notebooks. All seeds are fixed. Executing some or all code multiple times generates stable results. ...
0
votes
0
answers
20
views
The problem when working with requests using a proxy in Python
Sorry if some of the suggestions are going to be weird. I used a translator, because this question was not answered on my language's stackoverflow.
import threading
import requests
import random
...
0
votes
3
answers
40
views
Simulating random numbers in R using a certain condition
I would like to simulate 100 random numbers from N(0,1) in such a manner that the i-th number generated is always greater than the (i-1)-th number. I've tried using the ifelse statement in R but ...
0
votes
0
answers
10
views
Random Sampling base on 1 column after Groupby
I have a Spark Table, which contains 400+ millions records/rows. I used spark.table to convert it into a DF.
The DF looks like this below
id pub_date version unique_id c_id ...
0
votes
1
answer
21
views
Testing randomness function without intended mean
I have a program that tests a randomness function for how truly random it is:
function testRandom(randomF, tests, intendedMean){
let total = 0;
for(let t = 0; t < tests; t++){
...
0
votes
3
answers
58
views
C# - Random Generator exclude last number from Array
I've just started my first little project in C# and with WinForms and I am stuck on this one feature for a few days now..
I have an Array with about 60 PictureBoxes in it and when i press a button, I ...
0
votes
1
answer
22
views
Scraping SofaScore votes using Xpath and google sheets
I'm trying to scrape the votes from SofaScore with google sheets using the importxml function.
I'm running into an issue because the class name has a random string at the end of it.
Example "...
-2
votes
0
answers
14
views
MySQL insert at random position
I want to build a poll where the answers are not assignable to the voters. But I need to keep track of who already voted. So I have two different MySQL tables, one for answers and one for voters. But ...
-1
votes
0
answers
37
views
rand() % (int) in a loop causing seg fault [closed]
I'm trying to make a Qlearning function for a basic automatic learning project.
pseudo code for Qlearning function here
When using rand() % 4; in espi_greed (which aim is to sometimes choose a random ...
1
vote
1
answer
33
views
Sample from groups, but n varies per group in R
I am trying to randomly sample n times a given grouped variable, but the n varies by the group. For example:
library(dplyr)
iris <- iris %>% mutate(len_bin=cut(Sepal.Length,seq(0,8,by=1))
I ...
-1
votes
0
answers
31
views
Random div from csv list or from HTML [duplicate]
I have a recipe on this page: http://limitlesshoops.com/teams/tigers/recipes.html that I want to display as a random selection instead. I have a list of over 13,000 recipes in a csv that includes ...
0
votes
1
answer
34
views
Create new rows that are conditional on earlier rows
I want to create output_df, which adds two rows to the bottom.
The new rows are:
assigned NA for column z, and
percentage is calculated such that sum(output_df$x == "Y" & output_df$y == ...
-2
votes
0
answers
20
views
Display A Random Quote and Author from Array List in a New activity On Button Click
I'm trying to create a mood checker application. Where when the user clicks on a mood, it would display a quote in a new activity. My application runs but the quote is not displayed. I think there ...
-1
votes
0
answers
17
views
Is possible to randomize a value in JSON? [closed]
In java and in js there is the function Math.random(), is there something similar in JSON? Is possible to call that random value from another file or not?