Math & ScienceRandom seed

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

Random seed

Post by simo »

Random seed generate a unique value for random functions,like randompoly{},but am only able to do this manually.Do you have idea of how i can make this automatic?
I would appreciate so much to know about this.
Am using TeXnicCenter and Mavscript016

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Random seed

Post by frabjous »

Packages like random, rangen and lcg can generate random numbers for use in LaTeX documents. Is that what you're after?
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

Random seed

Post by simo »

Thanks a lot
Since the packages are not familiar do you have an idea of how I can change my randomseed{} value by using using the lcg package.
Its seems better from the documentation. There ain't any documentation for the random package at CTAN.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Random seed

Post by frabjous »

I've never used it, but playing around with it, you can for example generate four random numbers between 1 and 10 like this:

Code: Select all

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext,lipsum}
\usepackage[first=1,last=10]{lcg}
\begin{document}
The first value is \rand\arabic{rand}. 
 
The second value is \rand\arabic{rand}.
 
The third value is \rand\arabic{rand}.

The fourth value is \rand\arabic{rand}.
\end{document}
I can't really help you with what you're doing, without knowing more about what you're trying to do.

(Also, a bit annoyingly, it uses the time/date the file was saved to generate its seed, so you need to resave the file if you want new values the next time you run it.)
simo
Posts: 18
Joined: Thu Feb 04, 2010 4:27 pm

Random seed

Post by simo »

Am using mavscript which uses Yacas for compilation. The latex files contain the codes for the equations that are compiled to equations that have real values.I have tried to run it(above example)in Yacas but it is not generating any values until after .tex to pdf compilation.Here is an example of my case

Code: Select all

$m RandomSeed(76544321)$o
$m f1:=RandomPoly(x,4,-1,4) $o
If the RandomSeed() value changes by any value the RandomPoly() generates a different equation.
The issue now is to change the randomseed automatically which am only able to change manually but I need automatic.Lets say each user is supposed to get a different equation, then its not easy to keep on changing the randomseed manually all the time.

Thanks for your continued support,I believe we are getting somewhere.
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Random seed

Post by frabjous »

I don't know anything about mavscript or Yacas; in fact, I've never heard of them before, and your code means nothing to me. I still don't understand exactly what you're trying to do. (Bear with me; my degrees are all in philosophy!)

However, if you want real/decimal values, I'd suggest looking in to the rangen package, which is built on lcg, and has documentation for generating "real" numbers, and the documentation gives examples of using it to create random exam questions, etc.

I've never used any of these packages, so unless someone else can help you, I think reading the documentation for yourself will be more productive than anything I could offer.
Post Reply