What is expected to happen in a blank LibreOffice Calc document is when one types in a cell:
it returns 1.
What happens instead is it returns Err:502.
More information about multinomial may be found at:
Original bug at launchpad filed against 3.4, but also reproducible in master.
@Kohei, Eike: Please reassign (or self-assign) as appropriate.
Also: Possible regression?
Reproducible in LibreOffice 3.3.2.
Description: Ubuntu 10.04.3 LTS
apt-cache policy libreoffice-calc
*** 1:3.3.2-1ubuntu2~lucid1 0
500 http://ppa.launchpad.net/libreoffice/ppa/ubuntu/ lucid/main Packages
Ok, problem is just that we only support values up to 170 as paramters of MULTINOMIAL, I don't think that this is a regression.
Adjusting importance accordingly.
The presumed cause of the bug is that the multinomial is computed as a ratio of factorials; this would indeed cause an overflow when the sum of the arguments exceeds 170. Please note that for the implementation of the Binomial in LibreOffice Calc (function COMBIN) no such restriction applies; it is computed carefully to avoid unnecessary overflow.
Please note also that the bug with multinomial would be almost trivial to fix.
A recurrence for computing the multinomial function as a product of
binomials may be found in the description of the multinomial function in
the Sage mathematics system:
The associated 5-line Python code by Gabriel Ebner may be found here:
I believe that this is a very natural way to compute the multinomial, and it would completely remove the problem of unnecessary overflow.
Feel free to implement it. Source code for this function is at: http://opengrok.libreoffice.org/xref/core/scaddins/source/analysis/analysis.cxx#690
I'm looking forward to your contribution.
Proposed fix: https://gerrit.libreoffice.org/#/c/353
Created attachment 65063 [details]
Test file to check algorithm
Albert Thuswaldner committed a patch related to this issue.
It has been pushed to "master":
fdo#43135 - fix for MULTINOMIAL only supporting parameters up to 170