Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.asm.x86 > #1666

Re: Fast and small Multiplicative Random number generator

From hopcode <hopcode@nospicedham.nulnulul.de>
Subject Re: Fast and small Multiplicative Random number generator
Message-ID <jcsfv8$67m$1@online.de> (permalink)
Date 2011-12-21 12:29 +0100
Organization 1&1 Internet AG
References <jcnd08$ibm$1@online.de> <7c72de8e-a320-40dd-9d92-f2d7fcb710ee@32g2000yqp.googlegroups.com>
Newsgroups comp.lang.asm.x86, alt.lang.asm

Cross-posted to 2 groups.

Show all headers | View raw


Hi Hugh,

Il 21.12.2011 04:35, Hugh Aguilar ha scritto:
> On Dec 19, 6:08 am, hopcode<hopc...@nospicedham.nulnulul.de>  wrote:
>> Hi everybody,
>>
>> some days ago i started thinking upon a
>> fast and simple random number generator of few
>> lines of codes, wondering about the use of
>> MUL and RDTSC.
>
> Your algorithm isn't repeatable because it uses RDTSC, and I think
> that would eliminate it from consideration in most cases. During
> testing, people want to get the same stream every time. Also, your use
> of RDTSC might result in a not-very-random stream if your prng is
> called at a constant frequency, which is very likely to happen if it
> is called within a loop. All in all, I would prefer to stick with a
> traditional prng that gets seeded initially and then provides a stream
> determined solely by that seed.

ehm... good point, but difficoult for me to give an answer.
i'll try: assuming _T_ ime is cyclic, and _S_ omething in it changes
every seconds, we want correlate the two things.
permutations are not enough because even if,
for the fundamental rule, T x S are the number of resulting ways,
one can find in it _again_ the S or T, call it _fixed_ seed or
cyclical seed as from after issuing an RDTSC.

> Forth:
>
> 4294967291  constant rnd-unity          \ 2^32 - 5
> 3961633963  constant rnd-mult           \ 2^32 - 333333333
>
> macro:<prng>  ( rnd -- new-rnd )
>      rnd-mult um*  rnd-unity um/mod drop ;
>

someone told me that approaches like this have very bad distribution.
i cannot say it until i test it. i know from this last days that
operations only (correct me if i am wrong) like above quoted,
or operation+masking are not enough. we need to scramble all (bytes) 
values, because they all should be/act as semantically equals.
this is what i am trying to do just now, to let the algo behave more 
_stable_ . at the moment, i can say after some few modifications

- distribution is ok aftern ANDing results to 8/16/32 bits
- chi-square average between 40% and 70%

and the challenge is to have both stable, using T as seed. whenever
T is cyclic, the result should be random (so called "pseudo-random")
in that instant.

> It would be trivial to port to assembly language; I'll do that if
> anybody is interested. The only test that I applied was to make sure
> that it provides a full cycle through all of the 32-bit numbers other
> than zero, which it does. I don't know how to test it for randomness,
> although I should do that considering that I'm providing it as my prng
> in the novice package.

if You port it to assembly, i can execute ent and, eventually if the 
algo satisfies both conditions after ent, i.e
  - chi square
  - distribution

execute diehard on it and share results. coding conditions are simple:
preserve eventually RBP/RBX/RDI/RSI, result in RAX/EAX/AX/AL.

Cheers,

-- 
.:mrk[hopcode]
   .:x64lab:.
  group http://groups.google.com/group/x64lab
  site http://sites.google.com/site/x64lab

Back to comp.lang.asm.x86 | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

 Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-19 14:08 +0100
  Re: Fast and small Multiplicative Random number generator Markus Wichmann <nullplan@nospicedham.gmx.net> - 2011-12-19 21:10 +0100
     Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-20 07:33 +0100
      Re: Fast and small Multiplicative Random number generator "Rod Pemberton" <do_not_have@nospicedham.noavailemail.cmm> - 2011-12-20 11:06 -0500
   Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-20 14:59 +0100
    Re: Fast and small Multiplicative Random number generator Bernhard Schornak <schornak@nospicedham.web.de> - 2011-12-21 00:28 +0100
       Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-21 05:49 +0100
        Re: Fast and small Multiplicative Random number generator Bernhard Schornak <schornak@nospicedham.web.de> - 2011-12-22 13:19 +0100
           Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-22 22:30 +0100
            Re: Fast and small Multiplicative Random number generator Bernhard Schornak <schornak@nospicedham.web.de> - 2011-12-23 22:59 +0100
           Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-28 02:25 +0100
            Re: Fast and small Multiplicative Random number generator Bernhard Schornak <schornak@nospicedham.web.de> - 2011-12-29 00:34 +0100
  Re: Fast and small Multiplicative Random number generator Hugh Aguilar <hughaguilar96@nospicedham.yahoo.com> - 2011-12-20 19:35 -0800
    Re: Fast and small Multiplicative Random number generator "Harold Aptroot" <harold.aptroot@nospicedham.gmail.com> - 2011-12-21 12:21 +0100
     Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-21 12:29 +0100
      Re: Fast and small Multiplicative Random number generator Hugh Aguilar <hughaguilar96@nospicedham.yahoo.com> - 2011-12-21 05:45 -0800
         Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-21 18:40 +0100
          Re: Fast and small Multiplicative Random number generator Hugh Aguilar <hughaguilar96@nospicedham.yahoo.com> - 2011-12-22 15:42 -0800
             Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-23 02:24 +0100
    Re: Fast and small Multiplicative Random number generator "Rod Pemberton" <do_not_have@nospicedham.noavailemail.cmm> - 2011-12-21 14:48 -0500
   Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-27 14:19 +0100
    Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-28 14:04 -0800
       Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-29 02:13 +0100
        Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-28 18:43 -0800
           Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-30 05:50 +0100
            Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-29 21:31 -0800
               Re: Fast and small Multiplicative Random number generator  hopcode <hopcode@nospicedham.nulnulul.de> - 2011-12-30 08:20 +0100
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-30 08:34 -0800
      Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2011-12-29 17:33 -0800
        Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-29 20:52 -0800
        Re: Fast and small Multiplicative Random number generator Robert Wessel <robertwessel2@nospicedham.yahoo.com> - 2011-12-30 01:18 -0600
          Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2011-12-30 00:19 -0800
            Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2011-12-30 00:53 -0800
            Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-30 08:30 -0800
              Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2011-12-30 17:16 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-30 22:52 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2011-12-31 03:23 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2011-12-31 08:45 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-02 15:21 -0800
                Re: Fast and small Multiplicative Random number generator pete@nospam.demon.co.uk - 2012-01-03 09:01 +0000
                Re: Fast and small Multiplicative Random number generator Terje Mathisen <"terje.mathisen at tmsw.no"@giganews.com> - 2012-01-03 12:57 +0100
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-03 10:29 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-03 11:03 -0800
                Re: Fast and small Multiplicative Random number generator Terje Mathisen <"terje.mathisen at tmsw.no"@giganews.com> - 2012-01-03 22:18 +0100
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-03 14:22 -0800
                Re: Fast and small Multiplicative Random number generator "Rod Pemberton" <do_not_have@nospicedham.noavailemail.cmm> - 2012-01-03 21:36 -0500
                Re: Fast and small Multiplicative Random number generator "Rod Pemberton" <do_not_have@nospicedham.noavailemail.cmm> - 2012-01-03 21:40 -0500
                Re: Fast and small Multiplicative Random number generator hopcode <hopcode@nospicedham.invalid.de> - 2012-01-05 04:13 +0100
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-05 13:28 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-05 19:42 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-06 03:28 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-06 10:15 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-06 11:32 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-06 11:31 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-06 15:31 -0800
                Re: Fast and small Multiplicative Random number generator Frank Kotler <fbkotler@nospicedham.myfairpoint.net> - 2012-01-10 04:13 -0500
                Re: Fast and small Multiplicative Random number generator Jim Leonard <mobygamer@nospicedham.gmail.com> - 2012-01-10 09:54 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-10 16:38 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-10 17:21 -0800
                Re: Fast and small Multiplicative Random number generator hopcode <hopcode@nospicedham.invalid.de> - 2012-04-06 02:24 +0200
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-04-06 01:58 -0700
                Re: Fast and small Multiplicative Random number generator hopcode <hopcode@nospicedham.invalid.de> - 2012-04-06 13:55 +0200
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-10 17:19 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-11 03:39 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-11 18:28 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-11 03:37 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-11 16:59 -0800
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-11 19:22 -0800
                Re: Fast and small Multiplicative Random number generator hopcode <marcrainer.kranz@nospicedham.yahoo.com> - 2012-01-12 03:46 +0100
                Re: Fast and small Multiplicative Random number generator sfuerst <svfuerst@nospicedham.gmail.com> - 2012-01-11 18:56 -0800
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-11 20:58 -0800
              Re: Fast and small Multiplicative Random number generator Phil Carmody <thefatphil_demunged@nospicedham.yahoo.co.uk> - 2012-01-04 21:23 +0200
                Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-04 14:35 -0800
  Re: Fast and small Multiplicative Random number generator Pedro Pereira <ppereira@nospicedham.grupopie.com> - 2012-01-03 19:34 +0000
    Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-03 12:59 -0800
      Re: Fast and small Multiplicative Random number generator Pedro Pereira <ppereira@nospicedham.grupopie.com> - 2012-01-04 18:57 +0000
        Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-04 13:15 -0800
          Re: Fast and small Multiplicative Random number generator Pedro Pereira <ppereira@nospicedham.grupopie.com> - 2012-01-12 18:25 +0000
            Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-12 12:04 -0800
              Re: Fast and small Multiplicative Random number generator orz <cdhorz@nospicedham.gmail.com> - 2012-01-14 02:33 -0800
                Re: Fast and small Multiplicative Random number generator Pedro Pereira <ppereira@nospicedham.grupopie.com> - 2012-01-23 19:23 +0000
        Re: Fast and small Multiplicative Random number generator hopcode <hopcode@nospicedham.invalid.de> - 2012-01-05 03:53 +0100

csiph-web