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


Groups > comp.lang.c > #62747

Re: thread-safe random numbers...

From "Chris M. Thomasson" <nospam@nospam.nospam>
Newsgroups comp.lang.c
Subject Re: thread-safe random numbers...
Date 2015-05-28 13:57 -0700
Organization Aioe.org NNTP Server
Message-ID <mk7vg4$vu9$1@speranza.aioe.org> (permalink)
References <mk61l9$ap4$1@speranza.aioe.org> <mk7mam$5kv$1@dont-email.me> <87iobclch0.fsf@kst-u.example.com>

Show all headers | View raw


> "Keith Thompson"  wrote in message 
> news:87iobclch0.fsf@kst-u.example.com...

> > James Kuyper <jameskuyper@verizon.net> writes:
[...]
> > rand() has never been the recommended way of doing serious random number
> > generation - the standard imposes no meaningful restrictions on the
> > quality of the algorithm it uses. Older versions of the standard
> > actually gave a specific and very unsophisticated algorithm as an
> > example, and many implementations actually implemented that algorithm.
> > Creating your own random number generator, or borrowing someone else's,
> > is the recommended approach for serious random number generation. While
> > doing so, you can make it thread-safe.

> The current standard still has that sample implementation (as a
> non-normative example).

[...]


Are you perhaps referring to this one:
_________________________________________________
static unsigned long int next = 1;

int rand(void) // RAND_MAX assumed to be 32767
{
    next = next * 1103515245 + 12345;
    return (unsigned int)(next/65536) % 32768;
}

void srand(unsigned int seed)
{
    next = seed;
}
_________________________________________________


This can be easily modified to suit my needs.

FWIW, I am using these "random" numbers to pick
which complex root to follow during the processing
of an inverse nJulia set iterated function system.

Sometimes, the "quality" of the PRNG can start
to show some visual differences when I am caculating
a deep zoom on a given fractal by favoring certain
complex roots over the others...

Also, I am using a hybrid approach that relies on
more than one Julia point, so the PRNG is used
there as well...


;^) 

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-27 20:22 -0700
  Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 11:11 -0700
  Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 11:19 -0700
    Re: thread-safe random numbers... Rosario19 <Ros@invalid.invalid> - 2015-05-29 07:28 +0200
  Re: thread-safe random numbers... James Kuyper <jameskuyper@verizon.net> - 2015-05-28 14:22 -0400
    Re: thread-safe random numbers... Keith Thompson <kst-u@mib.org> - 2015-05-28 12:38 -0700
      Re: thread-safe random numbers... James Kuyper <jameskuyper@verizon.net> - 2015-05-28 16:42 -0400
      Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-05-28 13:57 -0700
      Re: thread-safe random numbers... Nobody <nobody@nowhere.invalid> - 2015-05-29 22:42 +0100
  Re: thread-safe random numbers... Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-10 11:56 -0700
    Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 14:03 -0700
      Re: thread-safe random numbers... Tim Rentsch <txr@alumni.caltech.edu> - 2015-07-11 13:44 -0700
  Re: thread-safe random numbers... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-10 12:01 -0700
    Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 13:53 -0700
      Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 13:58 -0700
      Re: thread-safe random numbers... "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-07-10 14:04 -0700
        Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 14:23 -0700
          Re: thread-safe random numbers... Keith Thompson <kst-u@mib.org> - 2015-07-10 17:12 -0700
            Re: thread-safe random numbers... "Chris M. Thomasson" <nospam@nospam.nospam> - 2015-07-10 18:58 -0700
      Re: thread-safe random numbers... Rosario19 <Ros@invalid.invalid> - 2015-07-11 11:13 +0200

csiph-web