ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Peter Rolf <indiego@gmx.net>
To: Hans Hagen <pragma@wxs.nl>
Cc: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: random seed
Date: Wed, 14 Nov 2012 21:15:11 +0100	[thread overview]
Message-ID: <50A3FBCF.8050905@gmx.net> (raw)
In-Reply-To: <50A3EF1A.8010405@wxs.nl>

Am 14.11.2012 20:20, schrieb Hans Hagen:
> On 11/14/2012 7:55 PM, Peter Rolf wrote:
>> Hi,
>>
>> in one of my documents I use a specific random seed to create a fixed
>> random based graphic (size, color, position). This works fine under
>> Windows (where I 'found' the seed value), but I get a complete different
>> result on my Debian system.
>>
>> Is there a way to get identical results on different OS? Or is the
>> random number generator OS specific? Just wondering...
> 
> yes and it cannot be trusted either (some underlying os code is used); i
> also found out that you need to call a couple of random's in a row first
> to get at least not the same ones in the beginning
> 
> in contetx I've now settled on:
> 
> math.initialseed =
> tonumber(string.sub(string.reverse(tostring(ceil(socket and
> socket.gettime()*10000 or time()))),1,6))
> 
> 
Thanks for the info. The formula looks like an incantation for the god
of random numbers ;-)

I already migrated the tex code to lua, so that I can do some post
processing on the collected random based data. To get identical results,
I only have to save the final data set then.

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


      reply	other threads:[~2012-11-14 20:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-14 18:55 Peter Rolf
2012-11-14 19:20 ` Hans Hagen
2012-11-14 20:15   ` Peter Rolf [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50A3FBCF.8050905@gmx.net \
    --to=indiego@gmx.net \
    --cc=ntg-context@ntg.nl \
    --cc=pragma@wxs.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).