It seems like everyone just uses set.seed(123) or set.seed(1234) when they are doing random sampling.  If so many people use just a select few integers for set.seed(), doesn't that mean that everyone is drawing from the same state of the random number generator and therefore all results are not a true random sample?
38410
In almost all of the analysis work that I've ever done I use:   set.seed(42)    It's an homage to Hitchhiker's Guide to the Galaxy. But I'm wondering if I'm creating bias by using the same seed over and over.
59448
The question is: n balls are distributed into n holes at random. What is the probability that exactly one hole remains empty. I came up with $$P\left(A\right)=\frac{\:\dbinom{n\:}{1}\:\dbinom{n\:-1}{1}\:\left(n-2\right)!}{n^n}$$ but was told I’m way way off. Yes, I do realize I’m awful at probability. Thanks for the help.
114462
I wonder whether for the average Linux user it is considered as bad -from a point of view of security or any other relevant viewpoints- to have no or almost no entropy left in /dev/random.   Edit: I don't need to generate random numbers (I would use /dev/urandom for that and even for password generation and disk encryption). Just for the fun of it, I have a bash script that generates strings of random characters out of /dev/random and of course, after playing a bit with it, I am left without entropy in /dev/random and it blocks. On IRC I was told it's "bad" to do so, but I wasn't given any reason. Is it bad because the average Linux user automatically generates random things using /dev/random? If so, which program(s) is/are involved?  I also understand that having no entropy left in /dev/random makes the generation of numbers deterministic. But again, is my computer (the average Linux user) in need of truly random numbers?   Edit 2: I've just monitored the entropy level every second in /dev/random during about 3 minutes, where I launched my bash script that uses entropy to generate a string of random character around the beginning of the monitoring. I've made a plot. We can see that indeed, the entropy level oscillates somehow, so some program(s) on my computer are using /dev/random to generate stuff. Is there a way I can list all programs using the file /dev/random?   We can also see that it takes less than a minute to yield "acceptable levels" of entropy once the entropy pool has been emptied.
1559
Consider the task of generating random points uniformly distributed within a circle of a given radius $r$ that is centered at the origin. Assume that we are given a random number generator $R$ that generates a floating point number uniformly distributed in the range $[0, 1)$.  Consider the following procedure:   Generate a random point $p = (x, y)$ within a square of side $2r$ centered at the origin. This can be easily achieved by:  a. Using the random number generator $R$ to generate two random numbers $x$ and $y$, where $x, y \in [0, 1)$, and then transforming $x$ and $y$ to the range $[0, r)$ (by multiplying each by $r$).  b. Flipping a fair coin to decide whether to reflect $p$ around the $x$-axis.  c. Flipping another fair coin to decide whether to reflect $p$ around the $y$-axis. Now, if $p$ happens to fall outside the given circle, discard $p$ and generate another point. Repeat the procedure until $p$ falls within the circle.   Is the previous procedure correct? That is, are the random points generated by it uniformly distributed within the given circle? How can one formally [dis]prove it?    Background Info  The task was actually given in . If you're interested, you can  in which I've implemented the procedure described above. I would like to know whether the procedure is mathematically correct or not, but I couldn't figure out how to formally [dis]prove it.  Note that the actual task was to generate random points uniformly distributed within a circle of a given radius and position, but I intentionally left that out in the question because the generated points can be easily translated to their correct positions relative to the given center.
121362
if we choose a size $25$ subset of the set: $\{1,2,....100\}$ what is the expectancy of the number of sequential pairs in the subset? expectancy still confuses me, can anybody help?
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.
44641
Assume I have a distribution governing the possible outcome from a single random variable X.  This is something like [0.1, 0.4, 0.2, 0.3] for X being a value of either 1, 2, 3, 4.  Is it possible to sample from this distribution, i.e. generate pseudo random numbers upon each of the possible outcomes given the probability of that outcome. So if I wanted to know what the probability of getting a 2 is, the sampling operation may return 0.34 or something like that.  The reason I ask is that I'm trying to implement an action selection policy for a reinforcement learning method based on a research paper. From what I gather from the paper, the author is able to sample the distribution by "mapping the uniform distribution U[0,1] through cumulative probability density functions obtained by adaptive numerical integration". From this he then samples the transition probabilities for each trial...  I would be grateful for any info on this...  Thanks in advance
38950
I see minecraft seeds listed, and I started trying some of my own.  I have noticed using the same seed produces very similar styles of maps, i.e. start in a specific biome, very high mountains etc, but do they reproduce the maps exactly and you just spawn in the same place, or are they just a very specific set of rules for the area you first spawn?   If I have two maps of the same seed, and I walk 1000 blocks north, will the maps be identical/similar or totally random after the first spawn area?
73153
I am programming a tile based game and I have some basic tiles (grass, dirt, etc..), but I can't figure out how to make good random map generation, because when I do some really random selection, if the tile should be grass/dirt, I get this:    I understand why this is happening, but what I want is to create some random continuous areas of grass or dirt. Something that would make more sense, like this:
106833
I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:  Vector itemsVector = getItems();  Collections.shuffle(itemsVector); itemsVector.setSize(5);   While this has the advantage of being nice and simple, I suspect it's not going to scale very well, i.e. Collections.shuffle() must be O(n) at least. My less clever alternative is  Vector itemsVector = getItems();  Random rand = new Random(System.currentTimeMillis()); // would make this static to the class      List subsetList = new ArrayList(5); for (int i = 0; i &lt; 5; i++) {      // be sure to use Vector.remove() or you may get the same item twice      subsetList.add(itemsVector.remove(rand.nextInt(itemsVector.size()))); }   Any suggestions on better ways to draw out a random subset from a Collection?
68990
Sample $k$ times with order from $n$ distinct numbers with replacement where $k\ge n$. Here "with order" means the sample is treated like a sequence rather than a set, so results like "1,3,3" and "3,1,3" are different.  The question is what is the probability that every number is sampled at least once? My answer is $1-\frac{{\sum\limits_{i = 1}^n {C_n^i\times i! \times {{(n - i)}^k}} }}{{{n^k}}}$ where $C_n^i$ denotes $n$ chooses $i$.  ${C_n^i\times i! \times {{(n - i)}^k}}$ means first choose $i$ ($i=1,2,...,n-1$) of numbers not to appear in the sample, and then we sample from the remaining $n-i$ numbers for $k$ times.   My question is, is there more elegant solution where the numerator can be directly computed? i.e. can we directly calculate the number of possible sample sequences in which every number has at least one occurrence? Thank you!    PS: my attempt was $C_k^n\times n!\times n^{n-k}$, meaning that we first choose $n$ positions in the sequence of length $k$ to place $n$ numbers, and then permute the $n$ numbers. This is to ensure every number to appear once. The remaining $n-k$ are sampled from the $n$ numbers without restriction.   However, I later found this seems not correct, and it counts the same sequence multiple times.  PS2: as pointed out in the comments, my first answer "1- ..." is not correct either.
123365
Consider a game that uses a generator which produces independent random integers between 1 and 100 inclusive. The game starts with a sum S = 0. The first player adds random numbers from the generator to S until S > 100 and records her last random number 'x'. The second player, continues adding random numbers from the generator to S until S > 200 and records her last random number 'y'. The player with the highest number wins, i.e. if y > x the second player wins. Is this game fair? Write a program to simulate 100,000 games. What is the probability estimate, based on your simulations, that the second player wins? Give your answer rounded to 3 places behind the decimal. For extra credit, calculate the exact probability (without sampling).     import random  CONST_TIMES = 100000 CONST_SMALL = 100 CONST_LARGE = 200  def playGame():     s = 0     while s &lt;= CONST_SMALL:          x = random.randint(1, CONST_SMALL)         s = s + x;     while s &lt;= CONST_LARGE:         y = random.randint(1, CONST_SMALL)         s = s + y     if x &lt; y:         return 's'     elif x == y:         return 'm'     else:         return 'f'  fst = sec = 0 for i in range(CONST_TIMES):     winner = playGame()     if winner == 'f':         fst = fst + 1     elif winner == 's':         sec = sec + 1 secWinPro = round(float(sec) / CONST_TIMES, 3)  print secWinPro   The simulation probability is about 0.524. I want to know how to calculate the exact probability.
76245
would someone please explain why the degrees of freedom for a random sample is n-1 instead of n ?   I'm looking for an explanation that is intuitive and easily understood by a high school student.
102177
I'm back again So there's another problem that I can't get to prove  If we take 21 numbers randomly from $1, 2, 3, ..., 40$ then between those $21$ numbers we will be able to find two numbers, of which the smaller one will divide the bigger one  I've been reading james hein "discrete structures, logic and computability" but still can't get to think logically myself. I would be very grateful if I could get some directions/tips/hints or anything, thanks in advance
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?
60370
When a map is created randomly, how can we find the seed that it has generated ?  I want to find some cool map in single player and when I'll find one, I want to get that seed and create it on my SMP server.
50029
How do I generate a random number between 0 and n?