[Openroad-users] Random Function
Doug White
black_belt101 at hotmail.com
Mon Dec 17 09:46:03 EST 2007
Ok, forgive me, i'm slow... how do i use the GetTickCount() to start the seed values for the openroad random function...
I can't find any documentation on these functions in the OpenROAD manuals
Doug White
Date: Sat, 15 Dec 2007 19:31:39 -0500
From: David.Tondreau at ingres.com
To: openroad-users at peerlessit.com
Subject: Re: [Openroad-users] Random Function
GetTickCount() returns the number of milliseconds since the system
was started which should be reasonably random…
http://msdn2.microsoft.com/en-us/library/ms724408.aspx
Regards,
David
David Tondreau
Architect, Ingres Corp.
http://community.ingres.com/
From:
openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Paul White
Sent: Friday, December 14, 2007 11:23 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Random Function
What about date_part(seconds,date('now)) ? (combined with
some other date/time values)
I wonder if we can get access to time values in milliseconds.
The OpenROAD profiling tracks time in milliseconds.
And I suppose you could use there is a WinAPI call to retrieve the
full system time.
From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Doug White
Sent: Saturday, 15 December 2007 2:12 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Random Function
That is much nicer,
Is there a way I can get a random seed if my app doesn't connect to a database?
Doug
Date: Fri, 14 Dec 2007 08:14:39 -0500
From: Sean.Thrower at ingres.com
To: openroad-users at peerlessit.com
Subject: Re: [Openroad-users] Random Function
Apologies – I should have been clearer – I meant that you use the
OpenROAD-local random() function throughout, having first got a random seed
from the database call: but you do it by using each locally-generated random
number to set limits for the next one, so as to avoid the situation where
the OpenROAD-local random() starts from the same seed each time at
application startup.
Initially:-
query = ‘SET RANDOM_SEED ’ +
:whatever;
//optional
EXECUTE IMMEDIATE
:query;
//optional
SELECT random(:low, :high) AS
randy;
Thereafter:-
low = lowfunction(randy); high =
highfunction(randy);
randy = random( :low, :high);
On reflection, it may even suffice to base the limits on the
database-generated seed just once, since thereafter the random number sequence
is emerging from a randomly chosen limit-set, so is randomly different from
every other application startup.
Initially:-
query = ‘SET RANDOM_SEED ’ +
:whatever;
//optional
EXECUTE IMMEDIATE :query;
//optional
SELECT random(:low, :high) AS
randy;
low = lowfunction(randy); high =
highfunction(randy);
randy = random( :low, :high);
Thereafter:-
randy = random( :low, :high);
Sean.
From:
openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com]
On Behalf Of Kim Ginnerup
Sent: Friday, December 14, 2007 12:01 PM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Random Function
If you can find the old tetris demo app for OpenROAD
You will find that OpenROAD actually has a built in random function
Kim
Fra:
openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] På vegne af Sean Thrower
Sendt: 14. december 2007 12:12
Til: International OpenROAD Users
Emne: Re: [Openroad-users] Random Function
Or maybe use the execute immediate select just to get the first
random number, then derive the next limit-values from each random value in turn
– random()-generated values from random limits should be random … - using Mod
if necessary to bring the final working value into range.
Sean.
Sean Thrower
Ingres Premium Services
From:
openroad-users-bounces at peerlessit.com [mailto:openroad-users-bounces at peerlessit.com]
On Behalf Of Bodo Bergmann
Sent: Friday, December 14, 2007 9:01 AM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Random Function
Or you coud just use the Ingres random() functions (see SQL Ref
Manual)
using a select (Execute Immediate if not supported directly).
Bodo
Bergmann
Senior
Software Engineer
OpenROAD
Worldwide Engineering
Ingres
Corp.
From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Doug White
Sent: Friday, December 14, 2007 9:02 AM
To: openroad
Subject: [Openroad-users] Random Function
Hey All,
I finally got sick of the crappy support for random number generation in
OpenROAD, So hopefully this can be of use to someone.
Enjoy, and please email me if you spot any problems / improvements that can be
fixed
P.S It's an exported application, that will probably only work in XP
Doug
White
Listen
now! New music from the Rogue Traders.
Find
it at www.seek.com.au Your Future Starts Here. Dream it? Then be it!
_________________________________________________________________
Overpaid or Underpaid? Check our comprehensive Salary Centre
http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fcontent%2Emycareer%2Ecom%2Eau%2Fsalary%2Dcentre%3Fs%5Fcid%3D595810&_t=766724125&_r=Hotmail_Email_Tagline_MyCareer_Oct07&_m=EXT
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071217/99ed60da/attachment.html
More information about the Openroad-users
mailing list