日期:2009-06-28  浏览次数:20396 次

Latest Snippet Version: 1.0

using System;

namespace Barsoom

{
    /// <summary>
    /// Good 31-bit Random Number Generator, returns Uint.
    /// </summary>
    /// <remarks>
    ///
    /// LICENSE : PUBLIC DOMAIN
    ///
    /// This is the base class for double and other statistical
    /// random number distribution classes
    ///
    /// Throws exception if initial seed is out of range.
    ///
    ///    Stephen K. Park and Keith W. Miller. RANDOM NUMBER GENERATORS:
    ///    GOOD ONES ARE HARD TO FIND. Communications of the ACM,
    ///    New York, NY.,October 1988 p.1192
    ///
    /// Throws exception if initial seed is out of range
    ///    This program is public domain and was written by Jill England
    ///    (Oct 1988).
    ///    
    /// Modifications;
    ///    
    /// Converted to C# from C++ and hacked heavily.  One major cool thing done
    /// here is to be able to SET the seed or get the next LCG value.
    /// 3/4/2002 JAE Jill@eskimo.com
    ///
    ///    Imported into Visual Studio .net, 3/1/2002 JAE jill@eskimo.com
    ///    
    /// To build the generator with the original ACM
    /// article's numbers use -DACM_ORIGINAL_NUMBERS when compiling.
    ///
    /// Original_numbers are those published m and q in the
    /// original ACM article.  John Burton, a Miller/Park, associate
    /// has furnished numbers for a reportedly better generator.  The
    /// new numbers are now used in this program by default.
    ///
    /// F(z)    = (az)%m
    ///            = az-m(az/m)
    ///
    /// F(z) =   G(z) + mT(z)
    /// G(z) = a(z%q) - r(z/q)
    /// T(z) =  (z/q) - (az/m)
    ///
    /// F(z) = a(z%q)- rz/q+ m((z/q) - a(z/m))
    ///      = a(z%q)- rz/q+ m(z/q) - az
    ///      
    /// NOTE JAE:    I could easily  extend this class to a C# 63 bit LCG but,
    ///                don't really see the point for most applications I have.
    ///                Besides 2**63 -1 is 9,223,372,036,854,775,807 that's 19
    //