tagged [random]

How to generate three random numbers, whose sum is 1?

How to generate three random numbers, whose sum is 1? I need to generate 3 random numbers, the amount of which is equal to 1. My implementation does not support uniform distribution. :(

6 Apr at 09:8

Best Way to Generate Random Salt in C#?

Best Way to Generate Random Salt in C#? Question says it all, what is the best method of generating a random salt (to be used with a hash function) in C#?

20 Jun at 18:27

Select random lines from a file

Select random lines from a file In a Bash script, I want to pick out N random lines from input file and output to another file. How can this be done?

11 Apr at 05:24

C# Random.Next - never returns the upper bound?

C# Random.Next - never returns the upper bound? It never returns the 5 (but sometimes returns the 0.) Why? I thought these are just boundary values that can be returned. Thanks

21 Feb at 07:16

shuffle (rearrange randomly) a List<string>

shuffle (rearrange randomly) a List I need to rearrange my List array, it has a non-determinable number of elements in it. Can somebody give me example of how i do this, thanks

21 Mar at 20:48

Random number between 0 and 1?

Random number between 0 and 1? I want a random number between 0 and 1, like 0.3452. I used `random.randrange(0, 1)` but it is always 0 for me. What should I do?

15 May at 18:44

Random shuffling of an array

Random shuffling of an array I need to randomly shuffle the following Array: Is there any function to do that?

16 Jun at 04:37

How do I create a list of random numbers without duplicates?

How do I create a list of random numbers without duplicates? I tried using `random.randint(0, 100)`, but some numbers were the same. Is there a method/module to create a list unique random numbers?

18 Dec at 17:51

Random number: 0 or 1

Random number: 0 or 1 Am I looking too far to see something as simple as pick a number: 0 or 1?

29 Sep at 15:0

How to generate a random number with a specific amount of digits?

How to generate a random number with a specific amount of digits? Let's say I need a 3-digit number, so it would be something like:

4 Jul at 14:31

How is a random number generated at runtime?

How is a random number generated at runtime? Since computers cannot pick random numbers(can they?) how is this random number actually generated. For example in C# we say, What happens inside?

How to generate a random string of a fixed length in Go?

How to generate a random string of a fixed length in Go? I want a random string of characters only (uppercase or lowercase), no numbers, in Go. What is the fastest and simplest way to do this?

13 Jul at 21:38

Expand a random range from 1–5 to 1–7

Expand a random range from 1–5 to 1–7 Given a function which produces a random integer in the range 1 to 5, write a function which produces a random integer in the range 1 to 7.

17 Jul at 05:1

Is there functionality to generate a random character in Java?

Is there functionality to generate a random character in Java? Does Java have any functionality to generate random characters or strings? Or must one simply pick a random integer and convert that inte...

13 Apr at 03:45

How does C#'s random number generator work?

How does C#'s random number generator work? I was just wondering how the random number generator in C# works. I was also curious how I could make a program that generates random numbers from 1-100.

25 Jun at 08:42

Unique random string generation

Unique random string generation I'd like to generate random unique strings like the ones being generated by MSDN library.([Error Object](http://msdn.microsoft.com/en-us/library/t9zk6eay.aspx)), for ex...

21 Aug at 19:17

Getting random numbers from a list of integers

Getting random numbers from a list of integers If I have a list of integers: How would I get 3 random integers from that list?

8 Jul at 15:21

Exclude values from Random.Range()?

Exclude values from Random.Range()? If you are using `Random.Range()` to generate values, is there any way to exclude some values within the range (for example: pick a number between 1 and 20, but not...

17 Jun at 13:36

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

Select N random elements from a List 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 elements from a `List`.

How can I select random files from a directory in bash?

How can I select random files from a directory in bash? I have a directory with about 2000 files. How can I select a random sample of `N` files through using either a bash script or a list of piped co...

1 Jul at 17:14

Shuffling a list of objects

Shuffling a list of objects How do I shuffle a list of objects? I tried [random.shuffle](https://docs.python.org/library/random.html#random.shuffle): But it outputs:

29 Jul at 04:45

How can I generate random numbers in Python?

How can I generate random numbers in Python? Are there any built-in libraries in Python or Numpy to generate random numbers based on various common distributions, such as: - - - - And various others? ...

31 Oct at 20:38

Sample random rows in dataframe

Sample random rows in dataframe I am struggling to find the appropriate function that would return a specified number of rows picked up randomly without replacement from a data frame in R language? Ca...

16 Jun at 04:36

Random date in C#

Random date in C# I'm looking for some succinct, modern C# code to generate a random date between Jan 1 1995 and the current date. I'm thinking some solution that utilizes Enumerable.Range somehow may...

13 Sep at 00:2

How to get random value out of an array?

How to get random value out of an array? I have an array called `$ran = array(1,2,3,4);` I need to get a random value out of this array and store it in a variable, how can I do this?

8 Sep at 11:38