Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #11385 > unrolled thread

Using a huge list of random numbers from random.org

Started bykbru157@gmail.com
First post2012-08-17 07:44 +0000
Last post2012-08-19 00:41 +0000
Articles 4 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Using a huge list of random numbers from random.org kbru157@gmail.com - 2012-08-17 07:44 +0000
    Re: Using a huge list of random numbers from random.org Roland Franzius <roland.franzius@uos.de> - 2012-08-18 07:57 +0000
      Re: Using a huge list of random numbers from random.org jarek@miszczak.eu - 2012-10-09 04:44 +0000
    Re: Using a huge list of random numbers from random.org Richard Fateman <fateman@cs.berkeley.edu> - 2012-08-19 00:41 +0000

#11385 — Using a huge list of random numbers from random.org

Fromkbru157@gmail.com
Date2012-08-17 07:44 +0000
SubjectUsing a huge list of random numbers from random.org
Message-ID<k0ksoc$66d$1@smc.vnet.net>
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?) 

[toc] | [next] | [standalone]


#11412

FromRoland Franzius <roland.franzius@uos.de>
Date2012-08-18 07:57 +0000
Message-ID<k0nht1$b39$1@smc.vnet.net>
In reply to#11385
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

[toc] | [prev] | [next] | [standalone]


#12009

Fromjarek@miszczak.eu
Date2012-10-09 04:44 +0000
Message-ID<k50a3n$3oq$1@smc.vnet.net>
In reply to#11412
On Saturday, August 18, 2012 9:57:21 AM UTC+2, Roland Franzius wrote:
> Am 17.08.2012 09:44, schrieb kbru157:
>
> > 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

I was wondering if it is possible to read some fixed number of bits (eg. 5) from the file with random data. I tried to use Import with "Bit" specification for this purpose, but this seams to be very slow. Are there any other methods to read from file bit-by-bit?

Best,

Jarek Miszczak

[toc] | [prev] | [next] | [standalone]


#11418

FromRichard Fateman <fateman@cs.berkeley.edu>
Date2012-08-19 00:41 +0000
Message-ID<k0pcnt$e36$1@smc.vnet.net>
In reply to#11385
On 8/17/2012 12:44 AM, kbru157@gmail.com wrote:
> 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?)
>



It might be worth considering whether your avoidance of some
  pseudo-random number generator is helpful.  In fact, if your
simulation is able to distinguish between a good pseudo-random
number generator and atmospheric noise, that would be quite
startling.

These random.org numbers are, philosophically speaking, not random at 
all, but completely determined.  An adversary could look at the first 
string of bits, discover which of the posted days of random atmospheric 
noise you are using, and then predict the next 8 million bits in 
sequence. That might, however, be irrelevant to you.


[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web