View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Seed generator using 'current' World Population count

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

Seed generator using 'current' World Population count


Pranam Janney (view profile)


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

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

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

PJ (view profile)

Different take on population count!

23 Aug 2010 Rob Campbell

Rob Campbell (view profile)

In absence of a reply to my question...

08 Jun 2010 Rob Campbell

Rob Campbell (view profile)

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.

Comment only
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.

Comment only
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:

or entering

>> doc regexp

at the MATLAB Command Prompt.

Specifically, look at example number 5.

03 Jun 2010 Pranam Janney

Pranam Janney (view profile)

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.

Comment only
03 Jun 2010 Rob Campbell

Rob Campbell (view profile)

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.

Comment only
03 Jun 2010 us

us (view profile)

please, remove this completely useless submission...

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


03 Jun 2010 1.1

Added read_specific_data.m

Contact us