xsl-list
[Top] [All Lists]

Re: Re: Re: A proposal:xsl:result-document asynchronous attribute

2003-03-11 13:33:52

"Kurt Cagle" <kurt(_at_)kurtcagle(_dot_)net> wrote in message
news:003501c2e806$d24d8a20$892afc0a(_at_)seatailslaptop(_dot_)(_dot_)(_dot_)
Nice. I'd missed this one. Any idea how even a distribution this gives?

-- Kurt

Quite sufficient for almost all uses with the exception of encryption
algorithms, perhaps. But see for yourself the results produced:

http://fxsl.sourceforge.net/articles/Random/Casting%20the%20Dice%20with%20FX
SL-htm.htm#2._Generating_a_random_sequence_following_a_distribution.Subseque
nces.

For example:

100 Random outcomes 1-6 with distribution:
<myDistribution:myDistribution>
<o>1</o><p>0.2</p>
<o>2</o><p>0.25</p>
<o>3</o><p>0.25</p>
<o>4</o><p>0.15</p>
<o>5</o><p>0.1</p>
<o>6</o><p>0.05</p>
</myDistribution:myDistribution>

Results:

2, 5, 1, 4, 3, 1, 2, 5, 4, 2,
2, 2, 1, 3, 2, 5, 2, 3, 3, 1,
1, 5, 4, 2, 5, 2, 2, 1, 1, 2,
4, 3, 1, 3, 6, 1, 2, 4, 4, 6,
3, 1, 4, 6, 2, 5, 2, 1, 1, 4,
2, 4, 2, 4, 3, 1, 3, 3, 3, 1,
4, 1, 5, 4, 1, 2, 2, 1, 6, 4,
4, 4, 2, 6, 5, 3, 2, 4, 3, 2,
2, 2, 3, 2, 3, 5, 4, 5, 2, 1,
3, 1, 2, 1, 3, 4, 2, 3, 2, 1,

As it can be seen, 6 appears for the first time only at position 35, and the
total is 5 out of 100 -- exactly the specified distribution of 0.02.

Needless to say, The original algorithm belongs to Simon Thompson and was
shamelessly reused by me from his excellent book "Haskell: The Craft of
Functional Programming".


For an explanation why the node-set randomisation algorithm is not perfect,
see:

http://haskell.org/pipermail/haskell/2003-March/011403.html

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>