RAND()

This is a discussion on RAND() within the MySQL Database forums, part of the Database Forums category; Nick Wedd <nick@maproom.co.uk> wrote: : Knuth's "Numerical recipes in C" explains what can ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 05-01-2008
thelma@uwm.edu
 
Posts: n/a
Default Re: RAND()

Nick Wedd <nick@maproom.co.uk> wrote:
: Knuth's "Numerical recipes in C" explains what can be wrong with
: system-supplied rand() functions. He wrote it 20 years ago, and things
: must have improved since then; but I still wouldn't trust a
: system-supplied rand(). He gives code for improving a system rand(),
: also for replacing it by one known to be good. His code is in C of
: course, but is quite short and is easily translated into other
: languages.


Donald Knuth, The Art of Computer Programming : Seminumerical Algorithms
You must be talking about one of the books in this series by Knuth.

Numerical Recipes in C is old enough that it started out as Numerical
Recipes in Fortran. It was written by Press and Teukolsky [and others]

--thelma

: Nick
Reply With Quote
  #12 (permalink)  
Old 05-02-2008
Nick Wedd
 
Posts: n/a
Default Re: RAND()

In message <QZ6dnd7j0a-GsofVnZ2dnUVZ_rzinZ2d@comcast.com>, Jerry Stuckle
<jstucklex@attglobal.net> writes
>Nick Wedd wrote:
>> In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfinZ2d@comcast.com>, Jerry
>>Stuckle <jstucklex@attglobal.net> writes
>>> Nick Wedd wrote:
>>>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdnZ2d@comcast.com>, Jerry
>>>>Stuckle <jstucklex@attglobal.net> writes
>>>>> Cosmic programmer wrote:
>>>>>> How good is the rand function of MySQL? How can it be improved?
>>>>>> Thx.
>>>>>> --
>>>>>> When you argue with a fool, chances are he's doing the same
>>>>>
>>>>> It's as good as pretty much any pseudo-random number generator.
>>>>>Why do you think it needs to be improved?
>>>> If it's only as good as any pseudo-random number generator, it
>>>>definitely needs to be improved.
>>>> Nick
>>>>
>>>
>>> And exactly how would you do that? Most pseudo-random number
>>>generators are pretty good, IMHO. And there is no such thing as a
>>>true random number generator.

>> Knuth's "Numerical recipes in C" explains what can be wrong with
>>system-supplied rand() functions. He wrote it 20 years ago, and
>>things must have improved since then; but I still wouldn't trust a
>>system-supplied rand(). He gives code for improving a system rand(),
>>also for replacing it by one known to be good. His code is in C of
>>course, but is quite short and is easily translated into other languages.
>> Nick

>
>So? You don't think the system programmers haven't improved in 20
>years? Unless you have a specific problem with it, why reinvent the
>wheel?


They have probably improved. I don't know how much they have improved.
If I need a RNG that works, I would rather use one that I know meets my
spec, rather than one that might meet my spec.

Nick

>In fact, I'll bet that in 20 years even Knuth's random number generator
>has been improved upon.

--
Nick Wedd nick@maproom.co.uk
Reply With Quote
  #13 (permalink)  
Old 05-02-2008
Jerry Stuckle
 
Posts: n/a
Default Re: RAND()

Nick Wedd wrote:
> In message <QZ6dnd7j0a-GsofVnZ2dnUVZ_rzinZ2d@comcast.com>, Jerry Stuckle
> <jstucklex@attglobal.net> writes
>> Nick Wedd wrote:
>>> In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfinZ2d@comcast.com>, Jerry
>>> Stuckle <jstucklex@attglobal.net> writes
>>>> Nick Wedd wrote:
>>>>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdnZ2d@comcast.com>, Jerry
>>>>> Stuckle <jstucklex@attglobal.net> writes
>>>>>> Cosmic programmer wrote:
>>>>>>> How good is the rand function of MySQL? How can it be improved?
>>>>>>> Thx.
>>>>>>> --
>>>>>>> When you argue with a fool, chances are he's doing the same
>>>>>>
>>>>>> It's as good as pretty much any pseudo-random number generator.
>>>>>> Why do you think it needs to be improved?
>>>>> If it's only as good as any pseudo-random number generator, it
>>>>> definitely needs to be improved.
>>>>> Nick
>>>>>
>>>>
>>>> And exactly how would you do that? Most pseudo-random number
>>>> generators are pretty good, IMHO. And there is no such thing as a
>>>> true random number generator.
>>> Knuth's "Numerical recipes in C" explains what can be wrong with
>>> system-supplied rand() functions. He wrote it 20 years ago, and
>>> things must have improved since then; but I still wouldn't trust a
>>> system-supplied rand(). He gives code for improving a system rand(),
>>> also for replacing it by one known to be good. His code is in C of
>>> course, but is quite short and is easily translated into other
>>> languages.
>>> Nick

>>
>> So? You don't think the system programmers haven't improved in 20
>> years? Unless you have a specific problem with it, why reinvent the
>> wheel?

>
> They have probably improved. I don't know how much they have improved.
> If I need a RNG that works, I would rather use one that I know meets my
> spec, rather than one that might meet my spec.
>
> Nick
>
>> In fact, I'll bet that in 20 years even Knuth's random number
>> generator has been improved upon.


Whatever works for you. I'd rather not have to reinvent the wheel.

Do you use your own os also, just because the ones out there might not
meet your spec?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #14 (permalink)  
Old 05-02-2008
Nick Wedd
 
Posts: n/a
Default Re: RAND()

In message <7e-dncDXA6bDZofVnZ2dnUVZ_hOdnZ2d@comcast.com>, Jerry Stuckle
<jstucklex@attglobal.net> writes
>Nick Wedd wrote:
>> In message <QZ6dnd7j0a-GsofVnZ2dnUVZ_rzinZ2d@comcast.com>, Jerry
>>Stuckle <jstucklex@attglobal.net> writes
>>> Nick Wedd wrote:
>>>> In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfinZ2d@comcast.com>, Jerry
>>>>Stuckle <jstucklex@attglobal.net> writes
>>>>> Nick Wedd wrote:
>>>>>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdnZ2d@comcast.com>, Jerry
>>>>>>Stuckle <jstucklex@attglobal.net> writes
>>>>>>> Cosmic programmer wrote:
>>>>>>>> How good is the rand function of MySQL? How can it be improved?
>>>>>>>> Thx.
>>>>>>>> --
>>>>>>>> When you argue with a fool, chances are he's doing the same
>>>>>>>
>>>>>>> It's as good as pretty much any pseudo-random number generator.
>>>>>>>Why do you think it needs to be improved?
>>>>>> If it's only as good as any pseudo-random number generator, it
>>>>>>definitely needs to be improved.
>>>>>> Nick
>>>>>>
>>>>>
>>>>> And exactly how would you do that? Most pseudo-random number
>>>>>generators are pretty good, IMHO. And there is no such thing as a
>>>>>true random number generator.
>>>> Knuth's "Numerical recipes in C" explains what can be wrong with
>>>>system-supplied rand() functions. He wrote it 20 years ago, and
>>>>things must have improved since then; but I still wouldn't trust a
>>>>system-supplied rand(). He gives code for improving a system
>>>>rand(), also for replacing it by one known to be good. His code is
>>>>in C of course, but is quite short and is easily translated into other languages.
>>>> Nick
>>>
>>> So? You don't think the system programmers haven't improved in 20
>>>years? Unless you have a specific problem with it, why reinvent the
>>>wheel?

>> They have probably improved. I don't know how much they have
>>improved. If I need a RNG that works, I would rather use one that I
>>know meets my spec, rather than one that might meet my spec.
>> Nick
>>
>>> In fact, I'll bet that in 20 years even Knuth's random number
>>>generator has been improved upon.

>
>Whatever works for you. I'd rather not have to reinvent the wheel.
>
>Do you use your own os also, just because the ones out there might not
>meet your spec?


Sure. Last time I needed a serious RNG, I implemented it myself. I
didn't reinvent it, I just translated the code from Knuth.

Nick
--
Nick Wedd nick@maproom.co.uk
Reply With Quote
  #15 (permalink)  
Old 05-02-2008
Captain Paralytic
 
Posts: n/a
Default Re: RAND()

On 2 May, 11:30, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Nick Wedd wrote:
> > In message <QZ6dnd7j0a-GsofVnZ2dnUVZ_rzin...@comcast.com>, Jerry Stuckle
> > <jstuck...@attglobal.net> writes
> >> Nick Wedd wrote:
> >>> In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfin...@comcast.com>, Jerry
> >>> Stuckle <jstuck...@attglobal.net> writes
> >>>> Nick Wedd wrote:
> >>>>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdn...@comcast.com>, Jerry
> >>>>> Stuckle <jstuck...@attglobal.net> writes
> >>>>>> Cosmic programmer wrote:
> >>>>>>> How good is the rand function of MySQL? How can it be improved?
> >>>>>>> Thx.
> >>>>>>> --
> >>>>>>> When you argue with a fool, chances are he's doing the same

>
> >>>>>> It's as good as pretty much any pseudo-random number generator.
> >>>>>> Why do you think it needs to be improved?
> >>>>> If it's only as good as any pseudo-random number generator, it
> >>>>> definitely needs to be improved.
> >>>>> Nick

>
> >>>> And exactly how would you do that? Most pseudo-random number
> >>>> generators are pretty good, IMHO. And there is no such thing as a
> >>>> true random number generator.
> >>> Knuth's "Numerical recipes in C" explains what can be wrong with
> >>> system-supplied rand() functions. He wrote it 20 years ago, and
> >>> things must have improved since then; but I still wouldn't trust a
> >>> system-supplied rand(). He gives code for improving a system rand(),
> >>> also for replacing it by one known to be good. His code is in C of
> >>> course, but is quite short and is easily translated into other
> >>> languages.
> >>> Nick

>
> >> So? You don't think the system programmers haven't improved in 20
> >> years? Unless you have a specific problem with it, why reinvent the
> >> wheel?

>
> > They have probably improved. I don't know how much they have improved.
> > If I need a RNG that works, I would rather use one that I know meets my
> > spec, rather than one that might meet my spec.

>
> > Nick

>
> >> In fact, I'll bet that in 20 years even Knuth's random number
> >> generator has been improved upon.

>
> Whatever works for you. I'd rather not have to reinvent the wheel.
>
> Do you use your own os also, just because the ones out there might not
> meet your spec?


I'm surprised he's using MySQL at all. I would have expected him to
have written his own RDBMS, just to be sure it was EXACTLY what he
wanted.

Reply With Quote
  #16 (permalink)  
Old 05-02-2008
Jerry Stuckle
 
Posts: n/a
Default Re: RAND()

Captain Paralytic wrote:
> On 2 May, 11:30, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> Nick Wedd wrote:
>>> In message <QZ6dnd7j0a-GsofVnZ2dnUVZ_rzin...@comcast.com>, Jerry Stuckle
>>> <jstuck...@attglobal.net> writes
>>>> Nick Wedd wrote:
>>>>> In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfin...@comcast.com>, Jerry
>>>>> Stuckle <jstuck...@attglobal.net> writes
>>>>>> Nick Wedd wrote:
>>>>>>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdn...@comcast.com>, Jerry
>>>>>>> Stuckle <jstuck...@attglobal.net> writes
>>>>>>>> Cosmic programmer wrote:
>>>>>>>>> How good is the rand function of MySQL? How can it be improved?
>>>>>>>>> Thx.
>>>>>>>>> --
>>>>>>>>> When you argue with a fool, chances are he's doing the same
>>>>>>>> It's as good as pretty much any pseudo-random number generator.
>>>>>>>> Why do you think it needs to be improved?
>>>>>>> If it's only as good as any pseudo-random number generator, it
>>>>>>> definitely needs to be improved.
>>>>>>> Nick
>>>>>> And exactly how would you do that? Most pseudo-random number
>>>>>> generators are pretty good, IMHO. And there is no such thing as a
>>>>>> true random number generator.
>>>>> Knuth's "Numerical recipes in C" explains what can be wrong with
>>>>> system-supplied rand() functions. He wrote it 20 years ago, and
>>>>> things must have improved since then; but I still wouldn't trust a
>>>>> system-supplied rand(). He gives code for improving a system rand(),
>>>>> also for replacing it by one known to be good. His code is in C of
>>>>> course, but is quite short and is easily translated into other
>>>>> languages.
>>>>> Nick
>>>> So? You don't think the system programmers haven't improved in 20
>>>> years? Unless you have a specific problem with it, why reinvent the
>>>> wheel?
>>> They have probably improved. I don't know how much they have improved.
>>> If I need a RNG that works, I would rather use one that I know meets my
>>> spec, rather than one that might meet my spec.
>>> Nick
>>>> In fact, I'll bet that in 20 years even Knuth's random number
>>>> generator has been improved upon.

>> Whatever works for you. I'd rather not have to reinvent the wheel.
>>
>> Do you use your own os also, just because the ones out there might not
>> meet your spec?

>
> I'm surprised he's using MySQL at all. I would have expected him to
> have written his own RDBMS, just to be sure it was EXACTLY what he
> wanted.
>
>


Good point, Paul :-)

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote
  #17 (permalink)  
Old 05-05-2008
toby
 
Posts: n/a
Default Re: RAND()

On May 1, 11:01 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Nick Wedd wrote:
> > In message <69qdnTw3ffk8Z4TVnZ2dnUVZ_qfin...@comcast.com>, Jerry Stuckle
> > <jstuck...@attglobal.net> writes
> >> Nick Wedd wrote:
> >>> In message <n8GdnZSDT8M7gIrVnZ2dnUVZ_vKdn...@comcast.com>, Jerry
> >>> Stuckle <jstuck...@attglobal.net> writes
> >>>> Cosmic programmer wrote:
> >>>>> How good is the rand function of MySQL? How can it be improved?
> >>>>> Thx.
> >>>>> --
> >>>>> When you argue with a fool, chances are he's doing the same

>
> >>>> It's as good as pretty much any pseudo-random number generator. Why
> >>>> do you think it needs to be improved?
> >>> If it's only as good as any pseudo-random number generator, it
> >>> definitely needs to be improved.
> >>> Nick

>
> >> And exactly how would you do that? Most pseudo-random number
> >> generators are pretty good, IMHO. And there is no such thing as a
> >> true random number generator.

>
> > Knuth's "Numerical recipes in C" explains what can be wrong with
> > system-supplied rand() functions. He wrote it 20 years ago, and things
> > must have improved since then; but I still wouldn't trust a
> > system-supplied rand(). He gives code for improving a system rand(),
> > also for replacing it by one known to be good. His code is in C of
> > course, but is quite short and is easily translated into other languages.

>
> > Nick

>
> So? You don't think the system programmers haven't improved in 20
> years? Unless you have a specific problem with it, why reinvent the wheel?
>
> In fact, I'll bet that in 20 years even Knuth's random number generator
> has been improved upon.


Indeed, many excellent PRNGs have been designed since then.
Nonetheless, both Knuth's and MySQL's are just fine for many uses. If
the OP has a particularly stringent requirement for his PRNG, then he
doubtless already knows about the diverse other PRNG algorithms out
there with various properties, so I won't bother providing links
(Google can). As others here point out, RNG "quality" isn't a one-
dimensional notion; it all depends on what one needs. (Bit like
choosing an RDBMS, haha, where likewise there is an abundance of
choice and differing sweetspots.)

>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================


Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:19 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0