| View previous topic :: View next topic |
| Author |
Message |
rademur Newbie

Joined: 30 Jun 2009 Posts: 2
|
Posted: Tue Jun 30, 2009 11:05 pm Post subject: Flaw of random number generator |
|
|
A pseudo random number generator's (PRNG) primary output are integer numbers which are normalized (i.e. divided by the maximum value of the PRNG) giving floating point numbers x between 0 and 1.
The flaw of the PRNG used in OOO is: The less significant bits of the number x are cut off, which means there are only 32768 different numbers the function RAND() returns. 32768 is by far too small a number to use this PRNG to solve serious problems. With this generator we are back in the time of 16bit processors.
To prove what I'm writing, just multiply a random number by 32768 and you will always get an integer number between 0 and 32767.
Is there another function available for Calc which returns better random numbers? Since I've been dealing a lot with PRNGs I could write my own PRNG code in C, C++ etc.. Is there a way to make this code available for OOO Calc?
Thank you for responding
rademur |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
|
| Back to top |
|
 |
rademur Newbie

Joined: 30 Jun 2009 Posts: 2
|
Posted: Wed Jul 01, 2009 2:55 am Post subject: |
|
|
Meanwhile I found this thread in another OOo forum, which covers the same topic.
http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=5010&p=23134&hilit=+random#p23134
The very poor properties of Calc's built-in rand() function seem to have been an issue since years as acknak is stating. Like him I'm wondering why nothing happened to improve the situation. If Calc is intended to be used for serious statistical investigations an up-to-date pseudo random number generator is overdue. This need not be a Mersenne twister. Considering the limited number of cells in a spreadsheet which can be handled in reasonable computing time, even linear congruential generators with carfully chosen modulus and multiplier, would do a god job.
rademur |
|
| Back to top |
|
 |
Villeroy Super User


Joined: 04 Oct 2004 Posts: 10065 Location: Germany
|
Posted: Wed Jul 01, 2009 4:02 am Post subject: |
|
|
The issue you linked had been fixed for v2.4. It still generates a maximum of 1-1/(2^15) but now including the zero as minimum.
Hardly anybody in this forum can answer the question why this or that is not included. Not a single developer here. You can meet the devs in the com.openoffice hierarchy of mailing lists.
You are certainly welcome to add your implementation of a random number generator.
http://development.openoffice.org provides links to all the primers regarding the source code.
http://education.openoffice.org is a more informal project also engaged with the development of the suite.
Each project has it's mailing list.
You could also wrap your C++ program as add-in providing a single function, say RAND.ADD(). _________________ Rest in peace, oooforum.org
Get help on http://forum.openoffice.org |
|
| Back to top |
|
 |
jrkrideau Super User

Joined: 08 Aug 2005 Posts: 6733 Location: Kingston ON Canada
|
Posted: Thu Jul 02, 2009 6:42 am Post subject: |
|
|
| rademur wrote: | Meanwhile I found this thread in another OOo forum, which covers the same topic.
http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=5010&p=23134&hilit=+random#p23134
The very poor properties of Calc's built-in rand() function seem to have been an issue since years as acknak is stating. Like him I'm wondering why nothing happened to improve the situation. If Calc is intended to be used for serious statistical investigations an up-to-date pseudo random number generator is overdue. This need not be a Mersenne twister. Considering the limited number of cells in a spreadsheet which can be handled in reasonable computing time, even linear congruential generators with carfully chosen modulus and multiplier, would do a god job.
rademur |
I don't think that Calc is intended for serious statistical investigations any more than Excel is. It certainly should not be used. At last report it is a bit better than Excel, probably not a good as gnumeric but spreadsheets are just not intended for statistical analysis. See http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html for some discussion of this.
That said, it looks like we really do need a better random number generator. _________________ jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2 |
|
| Back to top |
|
 |
David Super User


Joined: 24 Oct 2003 Posts: 5668 Location: Canada
|
Posted: Thu Jul 02, 2009 6:50 pm Post subject: Re: Flaw of random number generator |
|
|
| rademur wrote: | | 32768 is by far too small a number to use this PRNG to solve serious problems. |
For serious math, use a serious math program. This is an OFFICE suite. Think of people who work in offices, not in physics labs.
David. |
|
| Back to top |
|
 |
jrkrideau Super User

Joined: 08 Aug 2005 Posts: 6733 Location: Kingston ON Canada
|
Posted: Sun Jul 05, 2009 8:15 am Post subject: Re: Flaw of random number generator |
|
|
| David wrote: | | rademur wrote: | | 32768 is by far too small a number to use this PRNG to solve serious problems. |
For serious math, use a serious math program. This is an OFFICE suite. Think of people who work in offices, not in physics labs.
David. |
If the only tool you have is a hammer, you tend to see every problem as a nail.
Abraham Maslow _________________ jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2 |
|
| Back to top |
|
 |
|