[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: Random (Was: Cannot run KDE snapshot :()
From:       Waldo Bastian <bastian () suse ! de>
Date:       1999-12-10 11:36:04
[Download RAW message or body]

On Fri, 10 Dec 1999, Sean Harmer wrote:

> Hi all,
> 
> This is my first post to this group and I am quite new to KDE. Concerning your
> request/desire for a KSequence class to generate a series of random numbers. I
> have a small class do do this which I have attached along with a simple array
> template that I used when developing it. 

Isn't free software great, you say you need something and it get
mailed to you right away :-)

> It should be very easy to port the code to use any array class though. 

Can we relicence it as LGPL? That way we can put it in kdecore.

> The class uses the Long period (>2*10^18) random number generator
> of L'Ecuyer with Bayes-Durham shuffle and added safeguards as
> described in the Numerical Recipes book. It produces a random number
> on the interval (0,1). 

I'll add a method to produce integeres between 0 and N as well. What
would be the best way to do that? Something like:

return (m_lngShufflePos % N); ?

> However I have not tested my implementation of this method very thoroughly 
> as of yet, but it certainly gives acceptable results. Probably just a bit of fine 
> tuning needed in the smallest representable number etc. 

It problably is already more than good enough for KSameGame :-)

Cheers,
Waldo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic