File Exchange

image thumbnail

Seed generator using 'current' World Population count

version 1.1 (2.02 KB) by

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

0 Downloads

Updated

View License

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

 

Comments and Ratings (8)

PJ

PJ (view profile)

Different take on population count!

Rob Campbell

Rob Campbell (view profile)

In absence of a reply to my question...

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.

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.

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.

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.

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.

us

us (view profile)

please, remove this completely useless submission...

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

us

Updates

1.1

Added read_specific_data.m

MATLAB Release
MATLAB 7.9 (R2009b)

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

» Watch video