To comment on the following update, log in, then open the issue:
http://www.openoffice.org/issues/show_bug.cgi?id=47296





------- Additional comments from [EMAIL PROTECTED] Wed Sep 14 21:19:49 -0700 
2005 -------
Compile and run the test program:

[EMAIL PROTECTED] ooo]$ g++ -DDEBUG -Os -o hypgeom5 hypgeom5.cxx
[EMAIL PROTECTED] ooo]$ ./hypgeom5 123 70000 1234 1234567
population (N) = 1234567
 # success (M) = 1234
 # samples (n) = 70000
             x = 123
old: inf (7.582e-05 sec)
new: 8.56113475055104e-10 (0.0004709 sec)

The corresponding R's answer is:

> dhyper( 123, 1234, 1234567-1234, 70000 )
[1] 8.561135e-10

which matches my answer. :-)  I have of course checked many other cases against
R, which all turned out to be comparable.

Also, just like the previous test program, you can run it without arguments for
all cases for N = 0 to 100 in comparison to the old algorithm.  It was a "pass"
on my machine.

The major difference from my first submitted algorithm is that the new algorithm
does not put those factorial elements that would be removed later, thus avoiding
the unnecessary expansion and shrinkage of the containers.  For example, in my
first algorithm, sometimes the container expanded to over 100000, only to be
reduced to 50 later on.  That was way inefficient, and caused the calculation to
take way too much time.  Because of this improvement, a scenario that took over
10 seconds to complete by my first algorithm is now reduced to a fraction of a
second.

Note that my new algorithm handles large values pretty good.

I have also switched from using multiset to using a sorted vector, which
resulted in an extra 50% performance increase.  set/multiset is designed to be
efficient when a good mix of insertion, search, erasure is involved.  But
because my new algorithm only does insertion, I considered vector to be the
better choice, and it is indeed. :-)

I will prepare a patch sometime after tomorrow.  I have to go sleep now.

Kohei

---------------------------------------------------------------------
Please do not reply to this automatically generated notification from
Issue Tracker. Please log onto the website and enter your comments.
http://qa.openoffice.org/issue_handling/project_issues.html#notification

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to