Top "Random" questions

This tag is for questions pertaining to random numbers and their generators, whether pseudo-random or truly random.

Generate random array of floats between a range

I haven't been able to find a function to generate an array of random floats of a given length between …

python arrays random numpy
best practice to generate random token for forgot password

I want to generate identifier for forgot password . I read i can do it by using timestamp with mt_rand(), …

php security random timestamp token
Math.random() versus Random.nextInt(int)

What is the difference between Math.random() * n and Random.nextInt(n) where n is an integer?

java random
Better way to shuffle two numpy arrays in unison

I have two numpy arrays of different shapes, but with the same length (leading dimension). I want to shuffle each …

python numpy random shuffle numpy-ndarray
Simple Random Samples from a Sql database

How do I take an efficient simple random sample in SQL? The database in question is running MySQL; my table …

mysql sql postgresql random
Unique random string generation

I'd like to generate random unique strings like the ones being generated by MSDN library.(Error Object), for example. A …

c# random
Select N random elements from a List<T> in C#

I need a quick algorithm to select 5 random elements from a generic list. For example, I'd like to get 5 random …

c# algorithm collections random element
Generate random numbers uniformly over an entire range

I need to generate random numbers within a specified interval, [max;min]. Also, the random numbers should be uniformly distributed …

c++ random
Random number in range [min - max] using PHP

Is there a way to generate a random number based on a min and max? For example, if min was 1 …

php security random
How to generate a random number between a and b in Ruby?

To generate a random number between 3 and 10, for example, I use: rand(8) + 3 Is there a nicer way to do this (…

ruby random range