RegistrierenSidebar verstecken
Nickname: 
Passwort: 
Sitzung auf IP beschränken 

Pi Vs Random

Globaler Rang: 204
Gesamtpunkte: 101882
Nachrichten: 65
Dank: 66
+Votes: 43
Registriert : 15y 99d
xen`s Benutzerbild






Der Benutzer ist Offline
Pi Vs Random
Google/Übersetzer0Danke Schön!0Gute Nachricht!0Schlechte Nachricht! Link
something i just thrown together for people to play with:

GeSHi`ed javascript Quelltext für 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!
Globaler Rang: 1
Gesamtpunkte: 759870
Nachrichten: 431
Dank: 491
+Votes: 456
Registriert : 14y 277d












Der Benutzer ist Offline
RE: Pi Vs Random
Google/Übersetzer0Danke Schön!0Gute Nachricht!0Schlechte Nachricht! 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
Globaler Rang: 204
Gesamtpunkte: 101882
Nachrichten: 65
Dank: 66
+Votes: 43
Registriert : 15y 99d
xen`s Benutzerbild






Der Benutzer ist Offline
RE: Pi Vs Random
Google/Übersetzer0Danke Schön!0Gute Nachricht!0Schlechte Nachricht! 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!
Globaler Rang: 1
Gesamtpunkte: 759870
Nachrichten: 431
Dank: 491
+Votes: 456
Registriert : 14y 277d












Der Benutzer ist Offline
RE: Pi Vs Random
Google/Übersetzer1Danke Schön!0Gute Nachricht!0Schlechte Nachricht! 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, JanLitwin17, SwolloW, dangarbri haben dieses Thema abonniert und erhalten EMails bei einer neuen Nachricht.
1 Personen sehen sich diese Thema gerade an.
Dieses Thema wurde 4230 mal angesehen.