Difference between revisions of "Random"

From Wiki
Jump to navigation Jump to search
m
m
Line 1: Line 1:
 
This page describes how to use random (to produce pseudo-random values) in ConTeXt and MetaPost. The `uniformdeviate` function in MetaPost, by default, uses a seeded value. This is useful to generate the "same" random results each time the final product is generated, but hampers creating books that differ from each other on successive generations.
 
This page describes how to use random (to produce pseudo-random values) in ConTeXt and MetaPost. The `uniformdeviate` function in MetaPost, by default, uses a seeded value. This is useful to generate the "same" random results each time the final product is generated, but hampers creating books that differ from each other on successive generations.
  
Related commands include:
+
See the {{cmd|getrandomnumber}} command for details.
 
 
* {{cmd|getrandomnumber}} - Generates a pseudo-random number each time.
 
* {{cmd|ctxlua}}<tt>{math.randomseed(os.time())}</tt> - Sets the seed based on the computer's timestamp.
 
  
 
The random seed is stored in the `tuc` file so that you get the same output each time the file is compiled (otherwise, multiple compiles can lead to an infinite cycle and you may not get all the references correct). Another approach is to delete the tuc file between runs.
 
The random seed is stored in the `tuc` file so that you get the same output each time the file is compiled (otherwise, multiple compiles can lead to an infinite cycle and you may not get all the references correct). Another approach is to delete the tuc file between runs.

Revision as of 08:19, 31 March 2014

This page describes how to use random (to produce pseudo-random values) in ConTeXt and MetaPost. The uniformdeviate function in MetaPost, by default, uses a seeded value. This is useful to generate the "same" random results each time the final product is generated, but hampers creating books that differ from each other on successive generations.

See the \getrandomnumber command for details.

The random seed is stored in the tuc file so that you get the same output each time the file is compiled (otherwise, multiple compiles can lead to an infinite cycle and you may not get all the references correct). Another approach is to delete the tuc file between runs.