Autor Beitrag
Mitmischer 1703
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 754
Erhaltene Danke: 19

Win 7, Debian
Delphi Prism, Delphi 7, RAD Studio 2009 Academic, C#, C++, Java, HTML, PHP
BeitragVerfasst: So 08.06.08 16:03 
Hi DF!

Woher holt sich random seine Daten, wenn man nicht voher mit randomize initialisiert hat?

Ich hab' das dann mal ohne randomize ausprobiert, und mein Button, den ich da zufällig über den Bildschirm bewegen wollte, ist immer an dieselben Stellen gehüpft!

_________________
Die Lösung ist nicht siebzehn.
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: So 08.06.08 16:12 
random braucht eine startzahl. die ist am anfang immer gleich, es sei denn, sie wurde vorher mit randomize neu berechnet (mithilfe der uhrzeit oder so)
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: So 08.06.08 16:30 
Hallo,

ich glaube, bei Randomize wählt er die aktuelle Uhrzeit als Startwert (ohne diesen Aufruf ist der Wert 0). Anschließend werden mit diesem Wert die Zufallszahlen berechnet. Das ist dann zwar nicht mehr zufällig, es kommen ja keine neuen Faktoren rein, aber durch den Startwert werden sie dann doch jedesmal unterschiedlich. Wahrscheinlich wird noch eine Laufvariable mit einbezogen, damit auch jedes mal eine neue Zahl raus kommt.

Grüße,
Yogu
Mitmischer 1703 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 754
Erhaltene Danke: 19

Win 7, Debian
Delphi Prism, Delphi 7, RAD Studio 2009 Academic, C#, C++, Java, HTML, PHP
BeitragVerfasst: So 08.06.08 17:27 
Ok, Danke!

_________________
Die Lösung ist nicht siebzehn.
alzaimar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2889
Erhaltene Danke: 13

W2000, XP
D6E, BDS2006A, DevExpress
BeitragVerfasst: So 08.06.08 19:36 
Es handelt sich um Pseudo-Zufallszahlen, d.h. es ist immer die gleiche Abfolge (bei gleichem Startwert), dennoch sind sie gleichverteilt und 'sehen zufällig aus'. Das ist für statistische Simulationen enorm wichtig, denn wir wollen deterministische Abläufe, die also bei identischem Input immer den gleichen Output haben.

_________________
Na denn, dann. Bis dann, denn.
huuuuuh
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 665
Erhaltene Danke: 19

win xp, (win vista), win 7
VS 2008 Express Edition, VS 2010 Express Edition, VS 2010 Professionell
BeitragVerfasst: So 08.06.08 21:03 
in meinem mathebuch steht auch eine möglichkeit dafür, hoffe ich krieg das noch auf die reihe
startwert zwischen null und eins
pi wird addiert
3-mal quadrieren
nachkommastellen sind die zufallszahl und neuer startwert
hinterher noch multiplizieren mit der gewünschten höchstzahl