Category "random"

Why is my rock/paper/scissors game getting the same random number for multiple function calls?

I have made a functioning (if possibly extremely verbose) game of rock/paper/scissors. If I run the game by calling the function once over and over the 'compute

full width responsive image with image tag in Rails 4 app

Im using the code below to make header images appear randomly in a app I´m making. I want the images to span the whole width of the screen but somehow it

How to get the remaining sample after using random.sample() in Python?

I have a large list of elements (in this example I'll assume it's filled with numbers). For example: l = [1,2,3,4,5,6,7,8,9,10] Now I want to take 2 samples fr

JOptionPane with switch cases

Well, this code actually run but ended up with wrong output (specifically in "Randoms" cases) Note: it has a random generator for a random result or output I

Ensure the gensim generate the same Word2Vec model for different runs on the same data

In LDA model generates different topics everytime i train on the same corpus , by setting the np.random.seed(0), the LDA model will always be initialized and tr

How to get a random string of 32 hexadecimal digits through command line?

I'd like to put together a command that will print out a string of 32 hexadecimal digits. I've got a Python script that works: python -c 'import random ; print

Generate a two-digit positive random number in JavaScript [closed]

How can I implement a simple function in JavaScript that generates a random positive number that consists of only two digits?

Generating 1 random number within 0-256 range in x86 8086 tasm(16 bit) [duplicate]

At this point i have been learning assembly for about 6 months. My current project is a random number generator. I need to generate 1 random n

Generating isotropic steps with lengths distributed as exp(-x/lambda)

I'm writing a code about radiation transportation and have generated isotropic vectors as shown by my code. I'm now unsure about how to generate isotropic steps

Latin Hypercube Sampling from a normal distribution (Python)

How to generate 10 random numbers from normal distribution using latin hypercube sampling technique in python 2.7? The range of the random number should be 5 to

Creating copy of class instance with randomly init variable (python)

I need to initialize an instance of a class with a randomly generated number. I then need to use this instance in several different trials. However, I am havi

Fast real valued random generator in java

java.util.Random.nextDouble() is slow for me and I need something really fast. I did some google search and I've found only integers based fast random generat

Random document in ElasticSearch

Is there a way to get a truly random sample from an elasticsearch index? i.e. a query that retrieves any document from the index with probability 1/N (where N i

Best way to select random rows PostgreSQL

I want a random selection of rows in PostgreSQL, I tried this: select * from table where random() < 0.01; But some other recommend this: select * from table

How to generate a random UUID which is reproducible (with a seed) in Python

The uuid4() function of Python's module uuid generates a random UUID, and seems to generate a different one every time: In [1]: import uuid In [2]: uuid.uuid4(

Laravel str_random() or custom function?

Is the Laravel str_random() function random enough so that I can use it for IDs? For example: str_random(32); This produces a random string of length 32 mad

Pokemon API request generate 5 Pokémon at a time

I need help with how to fetch 5 random pokemon at a time instead of rendering all pokemon on the screen using react? // destructuring const [items, setItems] =

What is the minimum code required to produce random numbers in Elm?

I just want to see a random number. So here's an example straight out of the docs for the Random library. I expect Random.generate to accept a generator and a s

How can I generate a random number in a certain range?

How can I create an app that generates a random number in Android using Eclipse and then show the result in a TextView field? The random number has to be in a r

Random word guessing game

I want to create a word guessing game where the program randomly selects a word from my word list and the user has to guess the word. User can only guess one l