[Openroad-users] Random Function

David Tondreau David.Tondreau at ingres.com
Sun Dec 16 11:31:39 EST 2007


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. <http://ninemsn.com.au/share/redir/adTrack.asp?mode=click&clientID=832&referral=hotmailtaglineOct07&URL=http://music.ninemsn.com.au/roguetraders>  

	 

	
________________________________


	Find it at www.seek.com.au Your Future Starts Here. Dream it? Then be it! <http://a.ninemsn.com.au/b.aspx?URL=http%3A%2F%2Fninemsn%2Eseek%2Ecom%2Eau%2F%3Ftracking%3Dsk%3Ahet%3Ask%3Anine%3A0%3Ahot%3Atext&_t=764565661&_r=OCT07_endtext_Future&_m=EXT>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20071215/e904a518/attachment.html 


More information about the Openroad-users mailing list