go away spammer

Author Topic: true random number generator for Axon  (Read 4738 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
true random number generator for Axon
« on: January 24, 2010, 12:03:57 AM »
I created a new TRUE random number generator for WebbotLib that works great.

It basically relies on total random static in the ADC to create the seed, so if your mcu has ADC, this will work.

Follow the instructions in random_number_gen.h to use it. The other two files are examples of how to use it.

If your PC needs random numbers for an algorithm, just hook up your Axon by USB to be a true random number generator.

Webbot will probably add this to the next WebbotLib version, making it even easier to use.

experimental results:                     
65500   total number of random numbers                        
                           
0   1   2   3   4   5   6   7   8   9
6507   6543   6488   6590   6543   6497   6589   6775   6372   6596
9.934%   9.989%   9.905%   10.061%   9.989%   9.919%   10.060%   10.344%   9.728%   10.070%


edit: improved code to speed it up
« Last Edit: January 24, 2010, 08:40:18 AM by Admin »

Offline guncha

  • Jr. Member
  • **
  • Posts: 40
  • Helpful? 0
Re: true random number generator for Axon
« Reply #1 on: January 25, 2010, 12:07:43 AM »
Wow, I'm impressed. Good work!

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #2 on: January 26, 2010, 07:05:07 PM »
Sorry to nit-pick, but is the term "True" random number generator apply here?

For what i was taught, your method still isn't 'true' because with enough samples, the method of creating a number based on a particular seed could be reverse engineered, and the seed found; then when the generator is re-seeded; with a few initial samples to determine the seed value, all future values could be predicted.

One of the only 'true' computerized random number generator i know of uses the radioactive element from a smoke detector and a CMOS camera, and as the substance decays, random pixels are excited on the CMOS sensor; resulting in a physically impossible to predict random number.

I'm ready to insert foot into mouth here, because i could be way off as this was only an interest of mine in school, and i never went through the formal training.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: true random number generator for Axon
« Reply #3 on: January 26, 2010, 08:21:47 PM »
The seed can be changed at any time by taking a new ADC reading. If the seed can be predicted after only 3 or 4 outputs, then the seed can easily be changed after ever 3.

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #4 on: January 26, 2010, 08:51:18 PM »
At that point though, your 'random number' might as well be a single reading straight off the ADC with some scaling, and if so I might argue it's more fuzzy logic then a 'true' random number.

from wikipedia, http://en.wikipedia.org/wiki/Pseudorandom_number_generator
Quote
A pseudorandom number generator (PRNG) is an algorithm for generating a sequence of numbers that approximates the properties of random numbers. The sequence is not truly random in that it is completely determined by a relatively small set of initial values, called the PRNG's state.

Quote
Most computer "random number generators" are not hardware devices, but are software routines implementing generator algorithms. They are often supplied as library routines in programming language implementations, or as part of the operating system. These are more properly called pseudo-random number generators, since, being deterministic finite-state machines, they cannot produce truly random outputs

"True" random number generators in software are a thing of myth. If it were easy, then there would be no need for things like http://gamesbyemail.com/News/DiceOMatic

Sorry to rain in on your hard work, I just have images of my old professors screaming in my head about there are no such thing as  'true' random number generators for computers.


Here is what i was talking about btw,
http://inventgeek.com/Projects/alpharad/overview.aspx

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: true random number generator for Axon
« Reply #5 on: January 26, 2010, 09:04:16 PM »
One of the only 'true' computerized random number generator i know of uses the radioactive element from a smoke detector and a CMOS camera, and as the substance decays, random pixels are excited on the CMOS sensor; resulting in a physically impossible to predict random number.
Aren't we just looking at light-weight easy coding for the masses here rather than banking chip'n'pin ?

Sure - you could probably add all sorts of one-way encryption to avoid reverse engineering but not in a 'handfull of bytes'.

When Admin means 'true' then I think he means this:
If you just call random() then you get the next random number (according to a fixed algorithm) from a very long list.
Rebooting your chip will result in the same sequence of random numbers.
The only way to change the sequence is to seed the list with srandom() stating the starting point in the list. And thats the problem - coming up with a random number for srandom() without using random(). So his use of ADC noise is one approach.

So by using his code -then the program will receive a different sequence of random numbers each time - as opposed to the default C library behavior of returning the same list.

@madsci1016 - Not questioning what you say in 'theory' but sometimes theory can be overkill for practice! And as you say 'TRUE is a thing of myth' - so lets forget it !!

So if Admins ADC routine can come up with a random number for the seed - then why not just use it rather than calling random() ?

Well the answer is that the ADC addition may always end up with a small number - say a maximum of 100. So if you are trying to generate random numbers in the range 0 - 20,000 then it would be useless. But since Admin is using it as a seed value then the next call to random() can return a value in the complete variable range.

Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: true random number generator for Axon
« Reply #6 on: January 26, 2010, 09:06:37 PM »
Quote
At that point though, your 'random number' might as well be a single reading straight off the ADC with some scaling, and if so I might argue it's more fuzzy logic then a 'true' random number.
Well, its random in that its not predictable in any manner . . . it doesn't rely on only an algorithm in software.

All true random generators require hardware measurements.

Quote
A PRNG can be started from an arbitrary starting state using a seed state. It will always produce the same sequence thereafter when initialized with that state.
This doesn't happen if I use the ADC to continually change the seed value.

Anyway, as far as a robot creator is concerned, he'll always be guaranteed a new random sequence of values every time his bot is initialized.

(and yea, what Webbot said, too :P)

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #7 on: January 26, 2010, 09:14:56 PM »
Quote
@madsci1016 - Not questioning what you say in 'theory' but sometimes theory can be overkill for practice! And as you say 'TRUE is a thing of myth' - so lets forget it !!

I never argued that his code isn't valuable, efficient or worth using, (or better then the default C lib) just that using the word 'True' to describe it, is equivalent to claiming the invention of a perpetual motion machine; ie. academic suicide.

It can be a Really Really Ridiculously Good Looking (for people that CAN read good) Random Number Machine, but not a 'True' random number machine.

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #8 on: January 26, 2010, 09:19:52 PM »

This doesn't happen if I use the ADC to continually change the seed value.

This may be, however,

Quote
A physical random number generator can be based on an essentially random atomic or subatomic physical phenomenon whose unpredictability can be traced to the laws of quantum mechanics. Sources of entropy include radioactive decay, thermal noise, shot noise, avalanche noise in Zener diodes, clock drift, the timing of actual movements of a hard disk read/write head, and radio noise.
However, physical phenomena and tools used to measure them generally feature asymmetries and systematic biases that make their outcomes not uniformly random.


Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: true random number generator for Axon
« Reply #9 on: January 26, 2010, 09:25:46 PM »
Ok, better worded, '100% unpredictable random number generator' :P

Or even, 'functionally true random number generator'.


The user has no knowledge of the static electricity state, or the ability to control it, so its as good as random, no? ;D

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #10 on: January 26, 2010, 09:42:14 PM »
better, although I would still stray away form the absolute terms like '100%' and 'true' anything. It's enough of a gray area because both sides can argue convincing points, that's it's pretty accepted that there is no absolute truth either way.


We have this problem at my lab. We are one of the leading for-fronts in unmanned technology for they Navy, but anyone caught saying 'fully autonomous' or '100% autonomous' has pretty much put the brakes on their career permanently. Every systems requires human intervention at some point, thus negating a 'truly' autonomous system.


(And i still like my name better. Does no one remember zoolander? )
« Last Edit: January 26, 2010, 09:45:01 PM by madsci1016 »

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: true random number generator for Axon
« Reply #11 on: January 26, 2010, 09:47:21 PM »
Can we settle on a 'practical, quick and working random number generator' ? If not then I've "lost the will to contribute further" !

After all - a lot of the code relies on random() which is implemented by the AVR C library and is beyond all of our control!
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline madsci1016

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 1,450
  • Helpful? 43
    • Personal Website
Re: true random number generator for Axon
« Reply #12 on: January 26, 2010, 10:16:28 PM »
Yeah, I'm done. The voices in my head have settled down now.  ;D

As i said before; I'm sorry John if this got taken the wrong way at all. You code is absolutely wonderful and a big improvement over what was a sad excuse for 'random'. Please don't think any less of me for sort of 'calling you out'.

 And i don't think this discussion was a waste, as it could help educate any youngsters reading better understand the murky waters of the idea of 'truly random'; I think it breaks down to a mixture of physics and a dash of philosophy.

« Last Edit: January 26, 2010, 10:37:29 PM by madsci1016 »

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: true random number generator for Axon
« Reply #13 on: January 26, 2010, 10:42:03 PM »
Well, my code is always open to criticism (ie suggested adjustments to make it 'more' random :P). I'm not a professional programmer, after all ;D

 


Get Your Ad Here

data_list