Code covered by the BSD License  

Highlights from
Seed generator using 'current' World Population count

3.0

3.0 | 4 ratings Rate this file 15 Downloads (last 30 days) File Size: 2.02 KB File ID: #27822

Seed generator using 'current' World Population count

by

 

02 Jun 2010 (Updated )

Generates a seed that could be used to set the state for random number generation in matlab.

| Watch this File

File Information
Description

Random number generated using Matlab (i.e. rand, randperm,etc) is pseudo-random and not pure-random. This script provides a seed that can be used to set the state in order to generate "near-pure" random numbers using rand, randperm etc. The script grabs the "current" world population count from a website and jumbles up the digits and outputs the seed.

World population count is not "predicable' and randperm of digits inside 'current' world population count is highly random, thus the seed generated is helpful in generating "near-pure" random numbers

Usage:
sd = GenSeed; %generate seed
RandStream.setDefaultStream(RandStream('mt19937ar','seed',sd)); % set the state
rand(1,10) %generate "near-pure" random numbers

 

MATLAB release MATLAB 7.9 (R2009b)
Other requirements Needs an internet connection to access the website
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
26 Oct 2012 PJ

Different take on population count!

23 Aug 2010 Rob Campbell

In absence of a reply to my question...

08 Jun 2010 Rob Campbell

Someone correct me if I'm wrong, but this submission isn't doing what it's claiming to do: The seed is just the starting point for the random number generator. Changing the seed in the way described above will give a different set of pseudo-random numbers but it won't make the series of numbers itself any more or less random.

In situations where you want a new random seed then either population or CPU time are equally valid. World population is basically just an exponential function of CPU time so both are predictable. However, in selecting a new random seed the predictability isn't relevant (unless you're doing cryptography), you just want to set your random seed to a new value. Of course, there are also situations where you want the random seed to have the same value on each run.

06 Jun 2010 Richard Crozier

Does the website that provides the world population count take it's results from actual inputs of population figures from the real world, or, as I suspect more likely, does it just count up at a rate similar to the estimated rate of world population growth? If it's the second, then you might as well use the time on the computer.

04 Jun 2010 Greg Wolff

This is pretty slick, and works as advertised. I also gave it a high rating because I think its very creative. I bet its an application the creators of the population clock never envisioned. :)

If you are looking for some enhancement suggestions, you can tighten up the code a little bit for searching the HTML source text returned by the URLREAD function with regular expressions instead of read_specific_data.m

There is an example of reading HTML tags in text using regular expressions. You can locate it by going here:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/regexp.html

or entering

>> doc regexp

at the MATLAB Command Prompt.

Specifically, look at example number 5.

03 Jun 2010 Pranam Janney

us & Rob Cambell --> it was a mistake on my part to have omitted that specific file while uploading

Rob: The point is quite simple, clock time is 'predictable' however the change-in-world-population-count is not predictable.

To generate "near-pure" random numbers, it is necessary for the system to have an interface/input from the physical real world. In this scenario, the physical real world is the growth in human population, the interface is the count in human population numbers.

03 Jun 2010 Rob Campbell

Missing the function "read_specific_data"

What's the point of this, however? Why not just use the computer's clock to generate the random seed? This wouldn't require an internet connection to generate a random number.

03 Jun 2010 us

please, remove this completely useless submission...

??? Undefined function or method 'read_specific_data' for input arguments of
type 'char'.

us

Updates
03 Jun 2010

Added read_specific_data.m

Contact us