OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Flaw of random number generator

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc
View previous topic :: View next topic  
Author Message
rademur
Newbie
Newbie


Joined: 30 Jun 2009
Posts: 2

PostPosted: Tue Jun 30, 2009 11:05 pm    Post subject: Flaw of random number generator Reply with quote

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
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Tue Jun 30, 2009 11:16 pm    Post subject: Reply with quote

http://development.openoffice.org
_________________
Rest in peace, oooforum.org
Get help on http://forum.openoffice.org
Back to top
View user's profile Send private message
rademur
Newbie
Newbie


Joined: 30 Jun 2009
Posts: 2

PostPosted: Wed Jul 01, 2009 2:55 am    Post subject: Reply with quote

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
View user's profile Send private message
Villeroy
Super User
Super User


Joined: 04 Oct 2004
Posts: 10065
Location: Germany

PostPosted: Wed Jul 01, 2009 4:02 am    Post subject: Reply with quote

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
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6733
Location: Kingston ON Canada

PostPosted: Thu Jul 02, 2009 6:42 am    Post subject: Reply with quote

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
View user's profile Send private message
David
Super User
Super User


Joined: 24 Oct 2003
Posts: 5668
Location: Canada

PostPosted: Thu Jul 02, 2009 6:50 pm    Post subject: Re: Flaw of random number generator Reply with quote

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
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6733
Location: Kingston ON Canada

PostPosted: Sun Jul 05, 2009 8:15 am    Post subject: Re: Flaw of random number generator Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Calc All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group