ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Henri Menke via ntg-context <ntg-context@ntg.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Cc: Henri Menke <henri@henrimenke.de>
Subject: Re: Curiosity about math.random in LuaTeX
Date: Mon, 23 Aug 2021 17:06:39 +0200	[thread overview]
Message-ID: <926b50ba8615f70d15e3b3866a548622a715a385.camel@henrimenke.de> (raw)
In-Reply-To: <20210823144650.z6u4h5g4vvm7ll22@thierry-Latitude-5300>

On Mon, 2021-08-23 at 16:46 +0200, Thierry Horsin via ntg-context
wrote:
> Hi everybody.
> 
> I wonder how does math.random() work in context. I found that this
> subject was discussed more than ten years ago by Otared and Taco and
> Thomas. It is clear to me how to obtain new results upon typesetting
> the same file by changing the value of math.randomseed (with
> os.time()).
> 
> If you don't change the seed, you get the same result upon each
> typesetting, and a seed is given in the .tuc file.
> 
> For example I have this:
> ["randomseed"]=0x1.0741c18b8a4ep-6
> 
> How do I use (and is it possible to) this value to have the same
> result of math.random() upon typesetting another file (with a
> different name) ?
> 
> I could provide a same fixed seed in both files, but for some reasons
> I would like to re-use some previous results of math.random() for
> which no seed was initially given in another .tex file.

You can immediately forget about that, because in the past Lua has
switched the random number generator (RNG) between releases and also
uses a different RNG depending on the operating system. In general it
is a really bad idea to depend on the exact sequence of random numbers.

As an alternative you can just pregenerate a list of random numbers and
copy that to other documents.

Cheers, Henri

> 
> Thank you
> Thierry
> _____________________________________________________________________
> ______________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> _____________________________________________________________________
> ______________


___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

  reply	other threads:[~2021-08-23 15:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.91.1629714784.1197.ntg-context@ntg.nl>
2021-08-23 14:46 ` Thierry Horsin via ntg-context
2021-08-23 15:06   ` Henri Menke via ntg-context [this message]
2021-08-23 15:13   ` Hans Hagen via ntg-context
2021-08-23 15:24     ` Hans van der Meer via ntg-context
2021-08-23 15:49       ` Henri Menke via ntg-context
2021-08-23 16:25       ` Hans Hagen via ntg-context
2021-08-23 18:09     ` Thierry Horsin via ntg-context
2009-10-23  8:55 Otared Kavian
2009-10-23 19:44 ` Otared KAVIAN
2009-10-25  8:26   ` Taco Hoekwater
2009-10-25  9:50     ` Thomas A. Schmitz
2009-10-25 20:35       ` Otared Kavian

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=926b50ba8615f70d15e3b3866a548622a715a385.camel@henrimenke.de \
    --to=ntg-context@ntg.nl \
    --cc=henri@henrimenke.de \
    /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).