I had previously asked for a random number generator from within a range(), say 1-40, but this time around I am looking for a way in which a list of "unique" numbers is randomly generated from  a given set of values eg. 1,45, 23, 90, 23 etc.  Also, in the previous question, the program seems to generate the same random values every time it is executed and not saved.
121044
I searched for a similar question but couldn't find one..  I want to generate 10 groups out of numbers ranging from 1-60 (including both), with each and every group containing random and non-repeating numbers. How can I do this in excel?
22767
Is it possible to seed the random number generator () in JavaScript?
86190
Let T = {1000,1001...,9999}. How many numbers have at least one digit that is 0, at least one that is 1 and at least one that is 2. For example, 1072 and 2101 are two such numbers.  I have no idea to solve such probability question, I should use Permutation or Combination? why the answer is 150.  Thanks you guys.
55325
Given a sorted input file (or command output) that contains unique numbers, one per line, I would like to collapse all runs of consecutive numbers into ranges such that  n n+1 ... n+m   becomes  n,n+m     input sample:  2 3 9 10 11 12 24 28 29 33   expected output:  2,3 9,12 24 28,29 33
98634
How do I generate $n$ identically distributed but not independent normal random numbers such that their sum falls within a prespecified interval $[a,b]$ with probability $p$?  (This question is motivated by generating a random walk that ends up at a prespecified point: . Since a continuous random variable has zero probability of reaching an exact number, we do the second best thing and ask for an entire interval to end up in.)    EDIT:  has been proposed as a duplicate, which in turn is closed as a duplicate of . I agree that both of these are helpful. However, the point of the current question (more specifically, of the answer) is to first figure out that we can use a multivariate normal distribution to address the question, and second, what kind of covariance matrix works. How to sample from a distribution with that covariance is a third step, where the linked threads are helpful.
67033
When answering , I wrote up this , which works fine from my machine. However, on SE data, it always picks the same winner. Is it possible that SE Data fixes rand() to a specific number?  If so, why is that?
94938
In R, if I set.seed(), and then use the sample function to randomize a list, can I guarantee I won't generate the same permutation?  ie...  set.seed(25) limit &lt;- 3 myindex &lt;- seq(0,limit) for (x in seq(1,factorial(limit))) {     permutations &lt;- sample(myindex)     print(permutations) }   This produces  [1] 1 2 0 3 [1] 0 2 1 3 [1] 0 3 2 1 [1] 3 1 2 0 [1] 2 3 0 1 [1] 0 1 3 2   will all permutations printed be unique permutations?  Or is there some chance, based on the way this is implemented, that I could get some repeats?  I want to be able to do this without repeats, guaranteed.  How would I do that?  (I also want to avoid having to use a function like permn(), which has a very mechanistic method for generating all permutations---it doesn't look random.)  Also, sidenote---it looks like this problem is O((n!)!), if I'm not mistaken.
52342
I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible.  Any ideas?  Currently, I am doing something like this:  bool[] bIndexSet = new bool[iItemCount];  for (int iCurIndex = 0; iCurIndex &lt; iItemCount; iCurIndex++) {     int iSwapIndex = random.Next(iItemCount);     if (!bIndexSet[iSwapIndex] &amp;&amp; iSwapIndex != iCurIndex)     {         int iTemp = values[iSwapIndex];         values[iSwapIndex] = values[iCurIndex];         values[iCurIndex] = values[iSwapIndex];         bIndexSet[iCurIndex] = true;         bIndexSet[iSwapIndex] = true;     } }
120061
Shouldn't be repeated in any case; if the numbers appeared is exactly the same as another but different orders, that doesn't count as a new set. For example: $11,13,18,19,19,20$ is the same as $13, 18, 19,11,19,20$.
97040
How does one generate a random string sequence with Apex?  I need to generate a code when a particular object is created in our Salesforce environment.  I'd like the code to contain numbers from 0-9 and letters from A-Z.  Searching their rather awful developer forums I found:  Blob blobKey = crypto.generateAesKey(128); String key = EncodingUtil.convertToHex(blobKey); return key.substring(0,len);   However this isn't going to cover a very large range of letters.  In the C# world something like the following would do the trick:  var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var random = new Random(); var result = new string(     Enumerable.Repeat(chars, numberOfCharacters)               .Select(s =&gt; s[random.Next(s.Length)])               .ToArray() );   Is there an easy way to do something similar in Apex that I'm just not familiar with?
17336
is there some way to create unique number from 2 positive integer numbers? Result must be unique even for these pairs: 2 and 30, 1 and 15, 4 and 60. In general, if I take 2 random numbers result must be unique(or with very high probability unique)  Thanks a lot  EDIT: calculation is for computer program,so computational complexity is important
9180
First off, this question is ripped out from  question. I did it because I think this part is bigger than a sub-part of a longer question. If it offends, please pardon me.  Assume that you have a algorithm that generates randomness. Now how do you test it? Or to be more direct - Assume you have an algorithm that shuffles a deck of cards, how do you test that it's a perfectly random algorithm?  To add some theory to the problem - A deck of cards can be shuffled in 52! (52 factorial) different ways. Take a deck of cards, shuffle it by hand and write down the order of all cards. What is the probability that you would have gotten exactly that shuffle? Answer: 1 / 52!.  What is the chance that you, after shuffling, will get A, K, Q, J ... of each suit in a sequence? Answer 1 / 52!  So, just shuffling once and looking at the result will give you absolutely no information about your shuffling algorithms randomness. Twice and you have more information, Three even more...  How would you black box test a shuffling algorithm for randomness?
50344
Let A denote the set of those 6-digit positive integers in which each of the digits $1, 2, 3, 4, 5, 6$ appears exactly once. An integer in A, having standard decimal representation $d_1d_2 \cdots d_6$, is called nice if for each $k = 1, 2, 3, 4, 5$ the set {$d_1,.., d_k$} contains at least one digit strictly greater than $k$ (for example, 234561 is nice, whereas 321645 is not nice). From $A$, an integer $n$ is randomly picked. What is the probability that $n$ is nice?   My try:  Run the last digit from 1 through 6 and find the combinations by scanning the digits greater than the last digit across the first five positions in each of these scenarios.  It is pretty cumbersome and I am wondering if there could be anything simpler by means of symmetry or something like that as it does not give us any pattern. :  $234561 - 5!=120$  $345612 - 4*4! =96$  $456123 - 3*4!+3*3! = 90$  $561234 - 2*4!+4*3!+6*2! = 84$  $612345 - 1*4!+3*3!+8*2!+13*1! = 71$  $123456 - =0$  Total number of ways = $6! = 720$  Required probability = $$\frac{120+96+90+84+71}{720} = \frac{461}{720}$$  A simpler solution would be very much appreciated after verifying the answer.
29448
How do I pick a random element from a set? I'm particularly interested in picking a random element from a HashSet or a LinkedHashSet, in Java. Solutions for other languages are also welcome.
80007
Anyone have any ideas on this question? I think you have to use the pigeon hole principle..but I am not sure about that?     The numbers $1,2,3,\ldots,101$ are written down in a row in some order. Is it always possible to cross out $90$ numbers in a way such that all $11$ numbers left will stay either in increasing or decreasing order?
24187
Hello everybody! The problem you see above is a combinatorial problem that I could not solve. :(  Since we are to choose distinct numbers from $\{1,2,3 \ldots K\}$, the numbers must be in increasing order because they are all positive. I think that the difficulty of this problem is in the fact that the Special Sequence can be of any length. We can go about choosing say $n$ elements in $\binom{K}{n}$ ways but again how do we control that? Talking about a recursive solution, I think that is the way to go but I can't get how to do that (that is get a recursive formula for that).  Any help in solving this problem would be much appreciated. Thanks.
4926
The JavaScript  function returns a random value between 0 and 1, automatically seeded based on the current time (similar to Java I believe).  However, I don't think there's any way to set you own seed for it.  How can I make a random number generator that I can provide my own seed value for, so that I can have it produce a repeatable sequence of (pseudo)random numbers?