Discussion Overview
The discussion centers on the behavior of the rand() function in C, specifically whether it can return the same random number consecutively. Participants explore the implications of different implementations of rand() across platforms and libraries.
Discussion Character
- Debate/contested
- Technical explanation
- Exploratory
Main Points Raised
- One participant questions whether the function can return 1 or if it is always 0, suggesting that the probability of getting the same number twice could be zero or very small but non-zero.
- Another participant argues that without knowing the implementation details of rand(), it is impossible to definitively answer the question, referencing an xkcd comic that suggests avoiding rand().
- A participant mentions that the Microsoft implementation of rand() will never produce the same number consecutively but cycles through a finite set of values, raising concerns about the completeness of that set.
- Concerns are raised about the quality of Microsoft's rand() compared to other random number generators, with a suggestion to use the Boost library's Mersenne Twister instead.
- Several participants note that on Ubuntu Linux, the RAND_MAX value is significantly larger (2^31 - 1), leading to a belief that the implementation should be better, although one participant still criticizes Linux's rand() as being inadequate.
- Alternative methods for generating random numbers are proposed, including using programs that generate digits of e or pi, or downloading source code for better random number generators.
Areas of Agreement / Disagreement
Participants express differing views on the reliability and quality of the rand() function across different platforms, with no consensus on whether it can produce the same number consecutively. Multiple competing views on the effectiveness of various random number generators remain unresolved.
Contextual Notes
Participants highlight limitations in the rand() function's implementation, including finite output sets and varying quality across different systems, but do not resolve these issues.