Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #139125
| From | "Rick C. Hodgin" <rick.c.hodgin@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Multi-channel rand() |
| Date | 2018-12-27 10:28 -0500 |
| Organization | Liberty Software Foundation |
| Message-ID | <q02r0a$ldd$1@dont-email.me> (permalink) |
| References | (4 earlier) <aI2VD.166136$9q81.71538@fx12.am4> <e99ff17d-697e-4535-8734-094130ee79fc@googlegroups.com> <q02o8d$2gl$1@dont-email.me> <q02oa9$2gl$2@dont-email.me> <4e3785c7-aae8-4f61-9ac7-8a6b34fce17d@googlegroups.com> |
On 12/27/2018 10:01 AM, James Kuyper wrote:
> On Thursday, December 27, 2018 at 9:41:20 AM UTC-5, Rick C. Hodgin wrote:
>> On 12/27/2018 9:41 AM, Rick C. Hodgin wrote:
>>> On 12/27/2018 8:27 AM, James Kuyper wrote:
>>>> The documentation for random() says:
>>>> "Threaded applications should use erand48(), nrand48(), or jrand48()
>>>> instead of random() when an independent random number sequence in
>>>> multiple threads is required."
>>>
>>> In my particular case I'm not running a single thread. I just happen
>>> to need multiple random sources.
>>
>> Should say "I'm not running multiple threads, but running a single
>> thread only."
>
> Sorry - there have been several mentions of threading by other people on
> this thread, and I hadn't bothered reading your own messages, so I
> assumed "multi-channel" was your own personal way of saying "multi-
> threaded".
>
>>> Given the implementation of the algorithm, I'm surprised they didn't
>>> provide a native one that uses pointers to external values so you can
>>> have multiple rand() seeds and sources all working together.
>
> If POSIX functions are an acceptable solution, then, as Scott has
> already pointed out, the initstate() and setstate() functions can be
> used to make random() use different sets of state information, totally
> under your control. You responded to his message with a message about a
> Windows function, so it's not clear whether you noticed that part of
> what he was saying.
I did. It seems an undesirable solution due to the spill/fill overhead,
so I discounted it as a viable solution for me.
I was able to get the solution working based on Chris Thomasson's link
to the Permuted Congruential Generator (say that five times fast).
https://en.wikipedia.org/wiki/Permuted_congruential_generator
The code there can be modified easily to point to inputs for its "in-
ternal" values. No spill/fill required.
I think this type of solution is what should've been included in the
C standard's implementation. I think the need to potentially draw
multiple independently seeded pseudo-random values is a real need in
some coding models. And it's very little additional work to add the
ability natively.
--
Rick C. Hodgin
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-24 19:54 -0500
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-24 19:38 -0800
Re: Multi-channel rand() nobody@example.org (Scott) - 2018-12-25 04:05 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-24 23:57 -0500
Re: Multi-channel rand() Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-25 09:22 +0000
Professional coders??? (Was: Multi-channel rand()) gazelle@shell.xmission.com (Kenny McCormack) - 2018-12-25 10:09 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-25 07:59 -0500
Re: Multi-channel rand() Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk> - 2018-12-25 21:59 +0000
Re: Multi-channel rand() nobody@example.org (Scott) - 2018-12-26 02:43 +0000
Re: Multi-channel rand() rbowman <bowman@montana.com> - 2018-12-25 10:15 -0700
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-25 10:14 -0800
Re: Multi-channel rand() Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-12-25 13:35 +0300
Re: Multi-channel rand() fir <profesor.fir@gmail.com> - 2018-12-25 02:56 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-25 08:02 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-25 11:52 +0000
Re: Multi-channel rand() Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-12-25 14:58 +0300
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-25 06:59 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-25 08:05 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-25 08:04 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 15:48 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 07:58 -0800
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 12:06 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 12:45 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 13:20 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 10:30 -0800
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-26 11:35 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 14:52 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 16:31 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 22:28 -0500
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 20:42 -0800
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-26 15:32 -0800
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 19:38 +0000
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-26 15:35 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 12:59 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 16:05 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 13:08 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 15:50 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 17:42 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 12:48 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 12:58 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 19:03 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 14:45 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 20:46 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 16:25 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 17:13 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-26 22:23 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-26 23:39 +0000
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 17:36 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 16:27 -0500
Re: Multi-channel rand() rbowman <bowman@montana.com> - 2018-12-26 19:19 -0700
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-26 22:17 -0500
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-26 19:32 -0800
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-26 19:34 -0800
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-27 11:29 +0000
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 05:27 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 09:41 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 09:42 -0500
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 07:01 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 10:28 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-27 10:48 -0500
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 11:08 -0500
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-27 13:49 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 17:18 -0500
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-29 13:59 -0800
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 14:01 -0800
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-30 22:07 +0000
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-30 17:20 -0500
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-27 17:47 -0500
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-30 20:45 -0800
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 08:22 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 11:40 -0500
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 09:21 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 12:45 -0500
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 10:57 -0800
Re: Multi-channel rand() "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2018-12-27 14:35 -0500
Re: Multi-channel rand() Tim Rentsch <txr@alumni.caltech.edu> - 2018-12-28 09:25 -0800
Re: Multi-channel rand() Tim Rentsch <txr@alumni.caltech.edu> - 2018-12-28 09:55 -0800
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-28 12:36 -0800
Re: Multi-channel rand() Robert Wessel <robertwessel2@yahoo.com> - 2018-12-27 20:34 -0600
Re: Multi-channel rand() Richard Damon <Richard@Damon-Family.org> - 2018-12-27 10:37 -0500
Re: Multi-channel rand() Bart <bc@freeuk.com> - 2018-12-27 14:46 +0000
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 07:05 -0800
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-27 11:28 -0800
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 12:07 -0800
Re: Multi-channel rand() Keith Thompson <kst-u@mib.org> - 2018-12-27 12:47 -0800
Re: Multi-channel rand() James Kuyper <jameskuyper@alumni.caltech.edu> - 2018-12-27 14:47 -0800
Re: Multi-channel rand() "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-12-26 11:58 -0800
csiph-web