Mersenne Twister
MT19937 PRNG
Site Map Feedback

Download:

Up Rand Random ShortRand Twister

The Mersenne Twister algorithm creates 624 random numbers and presents them one at a time. Consequently, every 624th value you retrieve will take longer than the others. It is still a fast and well dispersed algorithm.

This version initially seeds itself from the system clock but can be seeded manually as well. The methods are all static. The fastest return is DWORD Get() a double GetDouble() is also provided. There are also two methods taking bounding values which return random numbers in the interval [a,b]:

  DWORD  Get(DWORD  a, DWORD  b);
  double Get(double a, double b);
Usage:
  gColor::gColor(bool Grey) : R(Twister::GetDouble()), G(Twister::GetDouble()), B(Twister::GetDouble()), A(Twister::GetDouble()) {if(Grey) R=G=B;}

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


 (1627) Last modified: Wed, 14 Jul 2010 21:10:27 +0100