Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Using a huge list of random numbers from random.org
Replies: 3   Last Post: Oct 9, 2012 12:44 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Roland Franzius

Posts: 253
Registered: 12/7/04
Re: Using a huge list of random numbers from random.org
Posted: Aug 18, 2012 3:57 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Am 17.08.2012 09:44, schrieb kbru157@gmail.com:
> I am doing some simulation which requires the use of random numbers. I do not want to use pseudo-random numbers. Instead I intend to download some of the binary files from random.org
> http://www.random.org/files/
> How do I use these digits within mathematica 8.0? (Subsidiary question: How would one convert these binary digits into deimal fractions?)
>


To use these 0-1 Random Digits directly makes sense only in the creation
process of a Random Number Generator.

For instance, you can add a large number N of
a*(0-1 Digits) -1 + b
in order to obtain a normal distribution with mean b and variance ~ N a.

Download eg. the 2012-07-22.txt file into your user directory and open
it in Mathematica as an input stream

Close[ips]
ips = OpenRead["C:\\Users\\MeTheUser\\Downloads\\2012-07-22.txt"]

Now you can start making experiments. The following examples interpret
the stream as integers of fixed lenght 64bit with 50:50 distribution of
binary digits. 0 and 1 are ASCII coded as characters by charcter code 48
and 49.


input = FromDigits[#, 2] & /@
Flatten /@ Partition[ReadList[ips, {Byte}, 1024], 64];

The -1,1- random generator is implemented as

choose[n_]:= 2*(Flatten@ReadList[ips, {Byte}, n] - 48-1/2);


From this you can construct an Gaussian generator by

gauss[n_]:= Plus@@choose[n]


A (0,1)-uniform generator is

uniform[n_] :=
N[Table[2^(-k), {k, 1, n}].Flatten[ReadList[ips, {Byte}, n]] - 48]

Here effectively each 0-1 is used to decide, if the resulting number
goes to the left or right half of the next 2^-n subdivison intervall on
(0,1) (1/2,1) (1/2,3/4) ... .


Using the uniform generator you can easily implement each distribution
with cumulative distribution function F: F(x) = Prob[ Variable <x ]

by

random:= InverseFunction[F][uniform[64]]

But be careful using a binary digits fixed length generator:
It has a fixed lattice structure.
Your problem should be insensitive to that length scale. But you can use
another random generator in order to decide the length of the binary
digit string to use.

--

Roland Franzius




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.