ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Gerben Wierda <gerben.wierda@rna.nl>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: METAPOST's uniformdeviate is not truly random (seed)
Date: Tue, 23 Jun 2020 17:57:59 +0200	[thread overview]
Message-ID: <02E331D9-C3E8-456D-B6EE-CD26E8E09C56@rna.nl> (raw)

I’m trying to get a real random number in METAPOST

MWE:

\startMPpage[instance=doublefun]
show uniformdeviate 60;
\stopMPpage

Every time I run this, it shows the same result. I tried playing around with the randomseed, but for instance when I do two runs shortly after each other they still are very predictable. E.g. this in METAPOST:

  whatever = lua( "math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )");
  randomseed := lua.math.random();
  minutespast := uniformdeviate 60;

Called shortly after each other (two LMTX runs) gets me the same result.

What is a good way to get better random numbers in METAPOST (LMTX)?

Thanks,

G
___________________________________________________________________________________
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:[~2020-06-23 15:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-23 15:57 Gerben Wierda [this message]
2020-06-23 16:14 ` Wolfgang Schuster

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=02E331D9-C3E8-456D-B6EE-CD26E8E09C56@rna.nl \
    --to=gerben.wierda@rna.nl \
    --cc=ntg-context@ntg.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).