i not want use system.random because slower , need generate millions of random floats. cannot use system.random.mwc because not pure.
i made attempt @ writing myself solution not generate uniform range, values close 0.
randomrmsp :: (float,float) -> puremt -> (float,puremt) randomrmsp (lo,hi) rng = let (f,rng') = first double2float (randomdouble rng) in (lo + f / (maxfloat + 1) * (hi - lo + 1),rng') maxrealfloat :: realfloat => -> maxrealfloat = encodefloat m n b = floatradix e = floatdigits (_, e') = floatrange m = b ^ e - 1 n = e' - e i'm pretty sure maxrealfloat function correct because returns correct values floats , doubles according wikipedia
i realized making silly mistake. function randomdouble in system.random.mersenne.pure64 returns double in range [0,1] (which documentation not mention @ all) , consquently numbers small because dividing them max double.
Comments
Post a Comment