----------------------------------------------------------------------------- -- | -- Module : Numeric.Random.Distribution.Geometric -- Copyright : (c) Matthew Donadio 2003 -- License : GPL -- -- Maintainer : m.p.donadio@ieee.org -- Stability : experimental -- Portability : portable -- -- UNTESTED -- -- Module for transforming a list of uniform random variables into a -- list of geometric random variables. -- -- @ P{X=n} = (1-p)^(n-1)*p @ -- -- Reference: Ross -- ---------------------------------------------------------------------------- module Numeric.Random.Distribution.Geometric (geometric) where -- * Functions -- | Generates a list of geometric random variables from a list -- of uniforms geometric :: Double -- ^ p -> [Double] -- ^ U -> [Double] -- ^ X geometric :: Double -> [Double] -> [Double] geometric Double p [Double] us = forall a b. (a -> b) -> [a] -> [b] map (\Double u -> Double 1 forall a. Num a => a -> a -> a + forall a. Floating a => a -> a log Double u forall a. Fractional a => a -> a -> a / forall a. Floating a => a -> a log (Double 1 forall a. Num a => a -> a -> a - Double p)) [Double] us