Thread View: sci.crypt
2 messages
2 total messages
Started by keith.willis
Thu, 20 Aug 1992 21:25
random values
Author: keith.willis
Date: Thu, 20 Aug 1992 21:25
Date: Thu, 20 Aug 1992 21:25
43 lines
1965 bytes
1965 bytes
If there is a more appropriate group for this, perhaps a
stats newsgroup, please let me know.
An aquaintance has a requirement for a large quantity of
truly random values. I believe the application for which
they are required is a genetic mutation simulator.
The way he has gone about getting this random data is a method
used in several encryption programs, namely asking the user to
type keys, and recording the intervals between keystrokes with
a hi-res timer. In fact, I believe he threw together a TSR
which trapped keystroke intervals over the course of a day or
so, in order to get a sufficient quantity of data.
This is fine as a random bitstream, but for his application,
he needs a set of random _values_, in a defined range, with
the constraint that there must be at least one of each
possible value. I am completely useless at stats, so could
people suggest how this might be achieved?
Thanks in advance.
---
~ PQ 2.15 194 ~
----- PGP v1.0 --- public key ------ keith.willis@almac.co.uk
section 1 of uuencode 5.15 of file willis.pub by R.E.M.
begin 644 keith.pub
MF;``0A8U*BI7:6QL:7,L($ME:71H("`@("!K96ET:"YW:6QL:7-`86QM86,N
M8V\N=6O>`^5^EYDE<?D,&>2!MNH>T+*/9_\.1-=WDSF_;.]<THIK/X]5R[T"
MY41S!CX_EE1=E;&V8PN<9*5?9],UV,J/(7S=`C-3S+>*+7`1T[8-8Q*@_@"I
LIR(5-E1Z*\@=1W42HU<X*^WG'GXL8#R0C@;=](&@IQ>0#2,4G@F9FS<%`!$%
`
end
sum -r/size 40780/274 section (from "begin" to "end")
sum -r/size 57997/179 entire input file
--
ALMAC BBS Ltd. 0324-665371
Dos based USENET access, call for details!
Re: random values
Author: Keith Lewis
Date: Fri, 21 Aug 1992 13:42
Date: Fri, 21 Aug 1992 13:42
29 lines
1736 bytes
1736 bytes
In article <1992Aug20.864.127@ALMAC>, keith.willis@almac.co.uk writes:
> This is fine as a random bitstream, but for his application,
> he needs a set of random _values_, in a defined range, with
You can convert from a random bitstream to a stream of random discrete
values (let's say, integers from 0..R) by the following algorithm.
Determine N, the number of bits you need (lowest N such that 2**N > R)
while (more bits available)
construct integer X out of next N bits (X = b(1)+2*b(2)+4*b(3)+...)
if X <= R
output X to stream
else
do nothing (discard bad X)
endwhile
For ranges that are exactly a power of two, this algorithm works perfectly.
For other ranges, it may discard (waste) almost half your bitstream.
> the constraint that there must be at least one of each
> possible value.
At least one of each possible value? That's a weird requirement. Could you
just add a list of all possible values onto the end of the stream?
Keith Lewis klewis@mitre.org "Mr. Cheap"
I don't dance to music; music dances to me. Email me for my PGP key.
The above may not (yet) represent the opinions of my employer.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads