![]() |
AW: Random: Delphi vs. Lazarus?
Namenloser,
wenn du moechtest kannst du mal folgendes ausprobieren: 1) Lasse dir ein paar Millionen Lottotips generieren fuer Lotto 6 aus 49 2) Danach erstelle eine Statistik fuer die Zahlen 1 bis 49 an welcher Stelle die Zahl in jedem Tipp vorkommt. Plotte die resultierenden sechs Hauefigkeitskurven (erste Stelle, zweite Stelle, ...) ueber die Zahlen 1 bis 49. Wenn du das einmal mit Delphi random machst und einmal mit einem besseren Generator machst wirst du sehen dass die Delphi random Werte schlecht sind und die Statistik stark verzerren. |
AW: Random: Delphi vs. Lazarus?
Zitat:
![]() Zitat:
Gruß, Sven |
AW: Random: Delphi vs. Lazarus?
Zitat:
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
var c0,c,c1 : Cardinal; begin c := GetTickCount; c0 := c; repeat c1 := GetTickCount; if c<>c1 then begin memo1.lines.add(intToStr(c-c0)); c := c1; End; until c1-c0>100; end; Zitat:
|
AW: Random: Delphi vs. Lazarus?
"The resolution of the GetTickCount function is limited to the resolution of the system timer, which is typically in the range of 10 milliseconds to 16 milliseconds."
![]() |
AW: Random: Delphi vs. Lazarus?
Zitat:
weisst du wie die Funktion random(pWert:integer):integer arbeitet? Ist das einfach:
Delphi-Quellcode:
Gruß
random:=zufallszahl mod pWert;
|
AW: Random: Delphi vs. Lazarus?
Nee
Delphi-Quellcode:
Es ist im Prinzip eher etwas wie
function Random(const ARange: Integer): Integer;
{$IFDEF PUREPASCAL} var Temp: Longint; begin Temp := RandSeed * $08088405 + 1; // berechne den nächsten Wert RandSeed := Temp; // Result := (UInt64(Cardinal(ARange)) * UInt64(Cardinal(Temp))) shr 32; end;
Delphi-Quellcode:
Result := Random * pWert; // Random liefert ja 0 bis 0.999999 (oder war es 0 bis 1?)
|
AW: Random: Delphi vs. Lazarus?
Hi Himitsu.
Zwei Dinge verstehe ich nicht.
|
AW: Random: Delphi vs. Lazarus?
Zitat:
Zitat:
Satty67 hat sich ![]() |
AW: Random: Delphi vs. Lazarus?
Zitat:
Delphi-Quellcode:
function Random: Extended;
const two2neg32: double = ((1.0/$10000) / $10000); // 2^-32 {$IFDEF PUREPASCAL} var Temp: LongInt; F: Extended; begin Temp := RandSeed * $08088405 + 1; RandSeed := Temp; F := Temp; Result := F * two2neg32; end; |
AW: Random: Delphi vs. Lazarus?
Zitat:
Delphi-Quellcode:
verwendete Interval [0,1) kann man
random
Delphi-Quellcode:
benutzen, und eine ähnliche Formel wenn man mehr als 32 Bit braucht.
//...
Result := (Temp + 2147483648.0) / 4294967296.0; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:37 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz