Username: 
Password: 
Restrict session to IP 

Pi Vs Random

Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 309d
xen`s Avatar






The User is Offline
Pi Vs Random
Google/translate0Thank You!0Good Post!0Bad Post! link
something i just thrown together for people to play with:

GeSHi`ed javascript code for pVr
1
2
3
4
56
7
<script>
num=5000;
 
z=0;x=0;pi="1415926535897932384626433832795028841971693993751058";
for (var i=0;i<num;i++){Check=(Math.random()/Math.random())+".";Check=Check.substr(4,1);if (Check==pi.substr(z,1)){if (z>x){x=z;document.write("Currently: "+x+"<br>")}z++;}else{z=0;}}
</script>


1000 monkeys and 1000 typewriters got me thinking, how well would a random number generator guess the decimals of Pi?
you can change variable "num" to the amount of numbers you wish to try.

also just for people learning:
WHICH=1>
loop Num times###>
1: Check=random number>
2: compare Check to WHICH digit of Pi>
3: if Check=WHICH digit of Pi then WHICH + 1 and print existing succession and start '1:' again
###
chmod ---x--x--x,, i'm illiterate!
Global Rank: 1
Totalscore: 759079
Posts: 437
Thanks: 496
UpVotes: 469
Registered: 15y 121d












The User is Offline
RE: Pi Vs Random
Google/translate0Thank You!0Good Post!0Bad Post! link
If you do a bit of maths, you can actual just calculate how well it does. (And you might just find it's as good at it as finding the decimals of 0 or any other sequence of digits.)

It could actually be a meaningful exercise, but more to realise how meaningless the "1000 monkeys and 1000 typewriters" thing is. ;)

B.t.w.: what is that piece of magic to get a random digit?

Regards,

downer... ehm... dloser
Global Rank: 202
Totalscore: 101919
Posts: 65
Thanks: 67
UpVotes: 44
Registered: 15y 309d
xen`s Avatar






The User is Offline
RE: Pi Vs Random
Google/translate0Thank You!0Good Post!0Bad Post! link
i thought maybe the random function of js could be not 100% random. and so decided to divide 2 random numbers (usually <1) to give more chance of randomness ;)
chmod ---x--x--x,, i'm illiterate!
Global Rank: 1
Totalscore: 759079
Posts: 437
Thanks: 496
UpVotes: 469
Registered: 15y 121d












The User is Offline
RE: Pi Vs Random
Google/translate1Thank You!0Good Post!0Bad Post! link
It isn't 100% random as that's pretty hard.

In any case, just applying some function to it to make it more random is a dangerous game. You wouldn't be the first person to shoot himself in the foot like that (for example, he might end up with Check being '.' instead of a digit). And think about it, if it were that simple, why wouldn't Math.random() already implement such tricks?

B.t.w.: you might want to check your "(usually <1)" statement. I'm not so sure about it.
tunelko, quangntenemy, TheHiveMind, Z, balicocat, Ge0, samuraiblanco, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, SwolloW, dangarbri, csuquvq have subscribed to this thread and receive emails on new posts.
1 people are watching the thread at the moment.
This thread has been viewed 4475 times.