ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> exslt
exslt
Re: [exslt] math:constant() and math:random()
by Uche Ogbuji other posts by this author
May 3 2002 4:11AM messages near this date
[exslt] Randomizing a node-list -- long (Was: Re: Extending xsltproc?) | RE: [exslt] XML -> PDF
>  Hi David,
>  
>  >> Hmm... I agree that this should be changed so that we avoid
>  >> side-effects. What about if we changed the signature to:
>  >>
>  >>   node-set math:random(number)
>  >>
>  >> and have math:random() return a number of <number> elements whose
>  >> values are random numbers between 0 and 1 (the number indicated by the
>  >> argument). The random numbers that are returned should be drawn from a
>  >> consistent set, such that if you do:
>  >>
>  >>   math:random(20)
>  >>
>  >> then the first 10 of the numbers are exactly the same as the numbers
>  >> that you would get if you did math:random(10). (Alternatively we could
>  >> just say that two calls to math:random() with the same argument must
>  >> result in the same set of random numbers.)
>  >>
>  >> The processor should, I think, produce a different set of random
>  >> numbers on each run of the particular stylesheet.
>  >
>  > Sounds good, but how about adding an optional "seed" argument? That
>  > would make it easier for users to get more than one set of return
>  > values.
>  
>  OK. We need to make it clear, then, whether this second seed argument
>  is actually used as the seed of the random sequence (such that if you
>  use the same seed in different transformations, you always get the
>  same random sequence), or if it's combined with something more random
>  (e.g. the date) by the processor in order to create a random sequence
>  that changes each time the transformation is run.
>  
>  I don't have any particularly strong feelings about it, but I imagine
>  that people who want to use random sequences will want those sequences
>  to be different each time the transformation is run.

Seeded RNGs are very widely used in simulation, and in testing scenarios, 
among other cases.

+1 for optional seed argument, where that seed is used independently of any 
other factors.


>  > Dmitre Novatchev also has a great implementation in his FXSLT
>  > library, so we could see what he's doing as well.
>  
>  Dimitre's templates generate a number of random numbers, with an
>  optional seed and an optional start and end scale. Given a generator
>  of random numbers between 0 and 1, I think a scaler can be fitted on
>  top easily enough.
>  
>  The other one of Dimitre's templates that's really cool takes a list
>  of value/probability pairs and generates a sequence of random numbers
>  that follows that distribution. Again, I think that this can be
>  implemented on top of a basic random() function, so I think that
>  math:random() is what we should concentrate on for now.

Agreed.  There are all sorts of distributions we can implement once we have a 
basic RNG.


-- 
Uche Ogbuji                           Fourthought, Inc.
uche.ogbuji@[...].com           http://fourthought.com
http://4Suite.org                     http://uche.ogbuji.net
Track chair, XML/Web Services One (San Jose, Boston): http://www.xmlconference.com/
RDF Query using Versa - http://www-106.ibm.com/developerworks/xml/library/x-think10/index.ht
ml
WSDL and the Wild, Wild West - http://adtmag.com/article.asp?id=6004
XML, The Model Driven Architecture, and RDF @ XML Europe - http://www.xmleurope.com/2002/ktt
rack.asp#themodel


_______________________________________________
exslt mailing list
list@[...].org
http://www.exslt.org/list

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved