|
Forum Index : Microcontroller and PC projects : CMM2 Random Number Test
| Author | Message | ||||
| Imgonna Newbie Joined: 06/08/2020 Location: United KingdomPosts: 15 |
A sweaty afternoon all (well here in the Wales / UK it's a sweaty 27'C) Getting hands on with CMM2 and loving it. I also love math and random numbers --- about to code up / benchmark some performance in calculating/estimating PI, so I need some reliable random numbers. I know the CMM2 generates random numbers through hardware -- does anyone know the specifics of this? (Just for geeky reference really). Currently iterating through generating 10,000,000 random numbers having started with 100,1000 etc. (generating 0 / 1 to simulate coin flipping) Looking at the numbers generated via ChiSquared statistics - to see if they random - results in p=0.898 --> ie random (as we would expect). Below is the code for 10,000,000 interations. I wonder how warm the CPU will get -- BTW loved the case mode for a fan also posted here. StartTime$ = "Start Time: "+ Time$ dim anum(2) for y = 1 to 1 anum(0)=0 anum(1)=0 For x = 1 to 10000000 num=int((rnd)*2) select case num case 0 anum(0)=anum(0)+1 case 1 anum(1) = anum(1)+1 end select if x mod 10000 = 0 then CLS Print StartTime$ Print "" print "Iteration", format$(x,"%.0f") endif next x Print "" print format$(anum(0),"%.0f"),format$(anum(1),"%.0f") next y Print "" Print "End Time: "+ Time$ Edited 2020-08-11 00:24 by Imgonna |
||||
| Imgonna Newbie Joined: 06/08/2020 Location: United KingdomPosts: 15 |
Hi For what it's worth - 10,000,000 iterations took 5 mins 31sec. Glen |
||||
| hitsware2 Guru Joined: 03/08/2019 Location: United StatesPosts: 734 |
I'm curious about a ' hardware ' random number generator ? A zener diode with counter ? Edited 2020-08-11 01:12 by hitsware2 my site |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
The onboard random generator is in the silicon (and thus hardware). If, however, you wanna play with something you can "scope", this might be interesting http://www.fruitoftheshed.com/Circuit%20Ideas.Random-Bit-Generator-for-cryptographic-strength-random-numbers.ashx Edited 2020-08-11 02:54 by CaptainBoing |
||||
| Imgonna Newbie Joined: 06/08/2020 Location: United KingdomPosts: 15 |
A quick Google of STM32 ARM and the spec sheet mentions "coupled oscillators" -- happy with that. Thanks for the link. Glen |
||||
| Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3308 |
The CPU keeps a constant speed regardless of what code it is executing or even if it is at the command prompt. So it will not heat up under heavy processing. Geoff Geoff Graham - http://geoffg.net |
||||
| Nimue Guru Joined: 06/08/2020 Location: United KingdomPosts: 425 |
Nice - my hacky logger has been recording for 18hrs now -- so no need to consider this. So, summer project is to make a hacky weather station...... Nim Entropy is not what it used to be |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |