Example Code

Get Truly Random Numbers from Random.org

Code and Documents

Attachment

Overview

Instead of relying on the native pseudorandom number generator, it is possible to gather genuinely random data from Random.org.

Description

Tired of LabVIEW's pseudorandom number generator?  Why not get truly random integers from random.org instead?  This VI fetches truly random integers from random.org using their published HTTP GET syntax:

http://www.random.org/clients/http/

Please see random.org's guidelines before running this code.

http://www.random.org/clients/

Of note:

-Do not call this VI in parallel (the VI is set to only allow one instance)

-Calling more numbers simultaneously is more efficient

Note that random.org limits the amount of data returned to an IP address to 200,000 bits per day (with a 1,000,000 initial deposit)

You can purchase more bits here:

http://www.random.org/clients/http/#quota.  This VI will return nonrandom data if you run out of bits, so you should periodically use "Remaining Quota From Random.org.VI" to determine remaining number of bits.

Steps to implement or Execute Code

  1. Load and run Remaining Quota from Random.org.vi in LabVIEW to determine how many remaining bits you have
  2. Load and run Get Integers from Random.org.vi to obtain random data from Random.org

Requirements

Software

LabVIEW 2011 or later

VI Snippets

getQuota.png

     Snippet of Remaining Quota from Random.org.vi

getRandomData.png

     Snippet of Get Integers from Random.org.vi

**This document has been updated to meet the current required format for the NI Code Exchange. For more details visit this discussion thread**

-John Sullivan
Problem Solver

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
WG-
Member
Member
on
Now_With_Underscores
NI Employee (retired)
on

Thanks for the heads up!  I should have searched community directly, not just ni.com  FYI:I played around with yours and can't get it to work on the Mac because Apple doesn't have a data socket server (Error 1181: Protocol not recognized).  Have a random day!

-John Sullivan
Problem Solver
WG-
Member
Member
on

Np. Thanks for the info, didn't know that, couldn't test it on MAC either since I have none. Anyway more code isn't bad 😉 could also have been that my code was already out-dated because the api might have been changed. I didn't looked threw your code yet, but I will in the next few days or so.    

Contributors