From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/112565 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hans van der Meer via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Curiosity about math.random in LuaTeX Date: Mon, 23 Aug 2021 17:24:50 +0200 Message-ID: <87E13377-AB93-48C9-B19E-970F2C32FF28@ziggo.nl> References: <20210823144650.z6u4h5g4vvm7ll22@thierry-Latitude-5300> <2c657a95-0fe5-de9b-dd07-14fd45007825@xs4all.nl> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Content-Type: multipart/mixed; boundary="===============2526569483241134733==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13302"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Hans van der Meer To: NTG ConTeXt Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 23 17:25:32 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mIBpL-00039K-RQ for gctc-ntg-context-518@m.gmane-mx.org; Mon, 23 Aug 2021 17:25:31 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 97BD9286C15; Mon, 23 Aug 2021 17:24:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id L9knVagmfAGt; Mon, 23 Aug 2021 17:24:54 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id CB071286C06; Mon, 23 Aug 2021 17:24:54 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5B740286C00 for ; Mon, 23 Aug 2021 17:24:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id f98mF_hCinCU for ; Mon, 23 Aug 2021 17:24:51 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=212.54.42.166; helo=smtpq3.tb.mail.iss.as9143.net; envelope-from=havdmeer@ziggo.nl; receiver= Original-Received: from smtpq3.tb.mail.iss.as9143.net (smtpq3.tb.mail.iss.as9143.net [212.54.42.166]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 64FA328698F for ; Mon, 23 Aug 2021 17:24:51 +0200 (CEST) Original-Received: from [212.54.42.106] (helo=smtp2.tb.mail.iss.as9143.net) by smtpq3.tb.mail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1mIBoh-0000kb-6a for ntg-context@ntg.nl; Mon, 23 Aug 2021 17:24:51 +0200 Original-Received: from [192.168.178.20] ([84.106.134.200]) by smtp2.tb.mail.iss.as9143.net with ESMTPA id IBogmFr7220j5IBohmvamQ; Mon, 23 Aug 2021 17:24:51 +0200 X-Env-Mailfrom: havdmeer@ziggo.nl X-Env-Rcptto: ntg-context@ntg.nl X-SourceIP: 84.106.134.200 X-CNFS-Analysis: v=2.4 cv=TYT1CTch c=1 sm=1 tr=0 ts=6123bdc3 cx=a_exe a=wCstmS+ZHA3zSJXjQC+ubA==:117 a=wCstmS+ZHA3zSJXjQC+ubA==:17 a=MiNTnEJAAAAA:8 a=YEMqx4UAAAAA:8 a=Uows8UApAAAA:8 a=ACQCx6kCAAAA:8 a=xtERp6CFAAAA:8 a=a3nu-2BBAAAA:8 a=KCAJOCk1QDx0bhFq9UkA:9 a=CjuIK1q_8ugA:10 a=Pg9fDbvR1kytMwWH:21 a=_W_S_7VecoQA:10 a=LmrbSfiT3hecnSZifb5M:22 a=V0662LiR8DSfwiDagK97:22 a=oX0v64vK4IwbpfTCMRm2:22 a=Sab0UneHBzlWrQDlOuxD:22 a=ekCXXmE-vB8RPiJ3MEZb:22 X-Authenticated-Sender: havdmeer@ziggo.nl DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ziggo.nl; s=202002corplgsmtpnl; t=1629732291; bh=kHJDkP8I05RM86FiKv1gFL6kdIS/z9Rb/ygvMPBQPxU=; h=From:Subject:Date:References:To:In-Reply-To; b=VEmAvDNlAMYWTG+PlQHI8qhfR7tKYrerqRQWfd54xyJh+xAqEBHRCecq35DUK1/K7 4W63NZ0ZHHnaeX0jGirNSvXQ893cVE3gRvDyWo8IV8FTDI5FJMwExZlrD0xFm7/NXV YDaBMPb4kO3h1CBUoN9i9fx/b+6oMuZ8s3SIfmcz34enR7ZQX9GXvO8a+voh1emu8d 9M8TKDa/H4mJE+940kUsbjcJbw6N/fVb1FW4SPjrkM9wUpxwdvNtwl6r7C19AkydQ7 cz8gYHYZXXDqvHqvX5tUYXXCn+8iz55OtU+0d8VIQgoo5GOwE3AXix4hsULBeMpsd2 UWZQ8wUI3gGBw== In-Reply-To: <2c657a95-0fe5-de9b-dd07-14fd45007825@xs4all.nl> X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CMAE-Envelope: MS4xfKIcdqZxDRrxU1zQgMmqjE8u3zNuRTT0i61TBvSpqEUWAWD8MJm5n9JIb/XEJ594VGnE/fuDiwZwdG13plBwXmKcfEcwo1ttSyAwE9kT8VCHnk2KvS0o XdzqtkYKsSCYfD8RhJAAScc7me/WToWIg2kynAJd9qjqOL3nZ2E40vt72oFDSiX5LDMK0kws7wfFlA== X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:112565 Archived-At: --===============2526569483241134733== Content-Type: multipart/alternative; boundary="Apple-Mail=_FBA61F73-94F7-410E-AFF0-67DDA1D88F93" --Apple-Mail=_FBA61F73-94F7-410E-AFF0-67DDA1D88F93 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I guess the underlying library calls are from Lua5.4? Then it is perhaps = useful to know that between 5.3 and 5.4 there is mentioned a new = implementation for math.random. Perhaps it changes the sequence of = random values generated? Someone who knows? dr. Hans van der Meer > On 23 Aug 2021, at 17:13, Hans Hagen via ntg-context = wrote: >=20 > On 8/23/2021 4:46 PM, 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"]=3D0x1.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 have to go low level ... >=20 > % \ctxlua{utilities.randomizer.setseed(0x1.0741c18b8a4ep-6)} > % \ctxlua{utilities.randomizer.setseed(0x1.6822232009d5p-5)} >=20 > \setrandomseed{123} >=20 > \starttext > test \randomnumber{1}{100} > test \randomnumber{1}{100} > test \randomnumber{1}{100} > \stoptext >=20 > btw, the 0x representation is lua's low level binary representation of = a double. >=20 > Hans >=20 > ----------------------------------------------------------------- > Hans Hagen | PRAGMA ADE > Ridderstraat 27 | 8061 GH Hasselt | The Netherlands > tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl > ----------------------------------------------------------------- > = __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry = to the Wiki! >=20 > 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 > = __________________________________________________________________________= _________ --Apple-Mail=_FBA61F73-94F7-410E-AFF0-67DDA1D88F93 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii I = guess the underlying library calls are from Lua5.4? Then it is perhaps = useful to know that between 5.3 and 5.4 there is mentioned a new = implementation for math.random. Perhaps it changes the sequence of = random values generated? Someone who knows?

dr. Hans van der Meer


On 23 Aug 2021, at 17:13, Hans Hagen via ntg-context <ntg-context@ntg.nl> = wrote:

On 8/23/2021 4:46 PM, 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"]=3D0x1.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 have to go low level ...

% = \ctxlua{utilities.randomizer.setseed(0x1.0741c18b8a4ep-6)}
%= \ctxlua{utilities.randomizer.setseed(0x1.6822232009d5p-5)}

\setrandomseed{123}

\starttext
   test = \randomnumber{1}{100}
   test = \randomnumber{1}{100}
   test = \randomnumber{1}{100}
\stoptext

btw, the 0x representation is lua's low level binary = representation of a double.

Hans

---------------------------------------------------------------= --
=             &n= bsp;           &nbs= p;            =     Hans Hagen | PRAGMA ADE
=             &n= bsp;Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
=       tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
---------------------------------------------------------------= --
_______________________________________________________________= ____________________
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
_______________________________________________________________= ____________________

= --Apple-Mail=_FBA61F73-94F7-410E-AFF0-67DDA1D88F93-- --===============2526569483241134733== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2526569483241134733==--