(use eggdoc) (define doc `((eggdoc:begin (name "random-mtzig") (description "An implementation of the MT19937 random number generator with Marsaglia and Tang's Ziggurat algorithm to generate random numbers from a non-uniform distribution.") (author (url "http://chicken.wiki.br/users/ivan-raikov" "Ivan Raikov")) (history (version "2.8" "Ported to Chicken 4") (version "2.7" "Added binomial sampling procedures") (version "2.6" "Build script updated for better cross-platform compatibility") (version "2.5" "Example updated to match 2.0 API [thanks to Terrence Brannon]") (version "2.4" "Bug fix in random-mtzig:f32vector-rande!") (version "2.3" "C interface bug fixes") (version "2.2" "Changed type definition for uint64_t so it doesn't collide with stdint.h") (version "2.1" "Bug fix in init procedure for vector case") (version "2.0" "Created reentrant interface") (version "1.0" "Initial release")) (requires) (usage "(require-extension random-mtzig)") (download "random-mtzig.egg") (documentation (p "The " (tt "random-mtzig") " library is Chicken Scheme wrapper for the MT19937 " "random number generator used in " (url "http://www.gnu.org/software/octave/" "GNU Octave") ". ") (subsection "Procedures" (procedure "random-mtzig:init :: [SEED] -> STATE" (p "Creates an initial seed array and returns the corresponding generator state vector. " "If the optional " (tt "SEED") " is not specified, " "the generator is initialized with a seed from " (tt "/dev/urandom") " or with the current time in seconds. " "If " (tt "SEED") " can be an integer or an " (tt "u32vector") ". ")) (procedure "random-mtzig:random! :: STATE -> INTEGER" (p "Returns a random integer value between 0 and the largest " "machine-representable unsigned integer on the current platform. ")) (procedure "random-mtzig:randu! :: STATE -> NUMBER" (p "Returns a random value from a uniform distribution on the " "interval " (tt "(0, 1)") ". ")) (procedure "random-mtzig:randn! :: STATE -> NUMBER" (p "Returns a random value from a normal (Gaussian) distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into a normal one. ")) (procedure "random-mtzig:rande! :: STATE -> NUMBER" (p "Returns a random value from an exponential distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into an exponential one. ")) (procedure "random-mtzig:randb! :: N * P * STATE -> NUMBER" (p "Returns a random value from a binomial distribution with " (tt "N") " experiments and probability " (tt "P") ". ")) (procedure "random-mtzig:f64vector-randu! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f64") " vector of random values " "from a uniform distribution on the interval " (tt "(0, 1)") ". ")) (procedure "random-mtzig:f64vector-randn! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f64") " vector of random values " " from a normal (Gaussian) distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into a normal one. ")) (procedure "random-mtzig:f64vector-rande! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f64") " vector of random values " " from am exponential distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into an exponential one. ")) (procedure "random-mtzig:f64vector-randb! :: N * P * XN * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f64") " vector of random values " "from a binomial distribution with " (tt "N") " experiments and probability " (tt "P") ". ")) (procedure "random-mtzig:f32vector-randu! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f32") " vector of random values " "from a uniform distribution on the interval " (tt "(0, 1)") ". ")) (procedure "random-mtzig:f32vector-randn! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f32") " vector of random values " " from a normal (Gaussian) distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into a normal one. ")) (procedure "random-mtzig:f32vector-rande! :: N * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f32") " vector of random values " " from am exponential distribution, using " "Marsaglia and Tsang's Ziggurat algorithm to transform " "a uniform distribution into an exponential one. ")) (procedure "random-mtzig:f32vector-randb! :: N * P * XN * STATE -> F64VECTOR" (p "Returns an SRFI-4 " (tt "f32") " vector of random values " "from a binomial distribution with " (tt "N") " experiments and probability " (tt "P") ". ")))) (examples (pre #< (require-extension random-mtzig) csi> (define st (random-mtzig:init 24)) csi> (random-mtzig:f64vector-randu! 20 st) #f64(0.960017303335919 0.699512049949576 0.999867292623879 0.220067299782852 0.361056353964058 0.739840990209437 0.996455725089097 0.316346977790608 0.136544579823525 0.3839800101516 0.320519283565193 0.366414753083515 0.709651562588127 0.900142430523374 0.534115439197721 0.247293764909945 0.671806562577075 0.561729107313138 0.54255987670951 0.893447603694901) EOF )) (license "Chicken Scheme egg scripts and documentation Copyright 2007-2009 Ivan Raikov. Coded by Takuji Nishimura and Makoto Matsumoto. This is a faster version by taking Shawn Cokus's optimization, Matthe Bellew's simplification, Isaku Wada's real version. David Bateman added normal and exponential distributions following Marsaglia and Tang's Ziggurat algorithm. Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, Copyright (C) 2004, David Bateman All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 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 COPYRIGHT OWNER 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.")))) (if (eggdoc->html doc) (void))