[Upstream] Calc: MULTINOMIAL only supports parameters up to 170

Bug #891812 reported by Bastiaan J. Braams
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LibreOffice
Fix Released
Wishlist
libreoffice (Ubuntu)
Fix Released
Wishlist
Unassigned

Bug Description

1)
Lucid:
lsb_release -rd
Description: Ubuntu 10.04.3 LTS
Release: 10.04

Oneiric:
lsb_release -rd
Description: Ubuntu 11.10
Release: 11.10

2)
Lucid:
apt-cache policy libreoffice-calc
libreoffice-calc:
  Installed: 1:3.3.2-1ubuntu2~lucid1
  Candidate: 1:3.3.2-1ubuntu2~lucid1
  Version table:
 *** 1:3.3.2-1ubuntu2~lucid1 0
        500 http://ppa.launchpad.net/libreoffice/ppa/ubuntu/ lucid/main Packages
        100 /var/lib/dpkg/status

Oneiric:
apt-cache policy libreoffice-calc
libreoffice-calc:
  Installed: 1:3.4.4-0ubuntu1~ppa1
  Candidate: 1:3.4.4-0ubuntu1~ppa1
  Version table:
 *** 1:3.4.4-0ubuntu1~ppa1 0
        500 http://ppa.launchpad.net/libreoffice/ppa/ubuntu/ oneiric/main i386 Packages
        100 /var/lib/dpkg/status
     1:3.4.3-3ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ oneiric/main i386 Packages

LibreOffice Calc 3.4.3, OOO340m1 (Build:302)

3) What is expected to happen in a blank LibreOffice Calc document is when one types in a cell:

=MULTINOMIAL(1000,0)

it returns 1.

4) What happens instead is it returns Err:502.

More information about multinomial may be found at:
http://help.libreoffice.org/Calc/Mathematical_Functions#MULTINOMIAL
http://office.microsoft.com/en-us/excel-help/multinomial-HP005209186.aspx

Revision history for this message
penalvch (penalvch) wrote : Re: Calc: multinomial(1000,0) returns Err502 instead of 1

Bastiaan J. Braams, thank you for taking the time to report this bug and helping to make Ubuntu better. The issue you are reporting is an upstream one and it would be nice if somebody having it could send the bug to the developers of the software by following the instructions at http://wiki.documentfoundation.org/BugReport . If you have done so, please tell us the number of the upstream bug (or the link), so we can add a bugwatch that will inform us about its status. Thanks in advance.

description: updated
Changed in libreoffice (Ubuntu):
importance: Undecided → Medium
status: New → Triaged
summary: - calc: numerical error in the multinomial function
+ Calc: multinomial(1000,0) returns Err502 instead of 1
description: updated
Changed in df-libreoffice:
status: New → Incomplete
Revision history for this message
Bastiaan J. Braams (bjbraams) wrote :

Thanks to Ch. Penalver for re-writing my bug report into the proper style. I hope that someone more experienced (than I) in the submitting of bug reports can take it upstream to libreoffice-calc.

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:

http://www.sagemath.org/doc/reference/sage/rings/arith.html#sage.rings.arith.multinomial

The associated 5-line Python code by Gabriel Ebner may be found here:

http://trac.sagemath.org/sage_trac/attachment/ticket/3132/trac3132-2.diff

Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

What is expected to happen in a blank LibreOffice Calc document is when one types in a cell:

=MULTINOMIAL(1000,0)

it returns 1.

What happens instead is it returns Err:502.

More information about multinomial may be found at:
http://help.libreoffice.org/Calc/Mathematical_Functions#MULTINOMIAL
http://office.microsoft.com/en-us/excel-help/multinomial-HP005209186.aspx

Original bug at launchpad filed against 3.4, but also reproducible in master.

Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

@Kohei, Eike: Please reassign (or self-assign) as appropriate.

Also: Possible regression?

Revision history for this message
In , penalvch (penalvch) wrote :

Reproducible in LibreOffice 3.3.2.

lsb_release -rd
Description: Ubuntu 10.04.3 LTS
Release: 10.04

apt-cache policy libreoffice-calc
libreoffice-calc:
  Installed: 1:3.3.2-1ubuntu2~lucid1
  Candidate: 1:3.3.2-1ubuntu2~lucid1
  Version table:
 *** 1:3.3.2-1ubuntu2~lucid1 0
        500 http://ppa.launchpad.net/libreoffice/ppa/ubuntu/ lucid/main Packages
        100 /var/lib/dpkg/status

Revision history for this message
Björn Michaelsen (bjoern-michaelsen) wrote :

Was the result correct in LibreOffice 3.3?

Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

What is expected to happen in a blank LibreOffice Calc document is when one types in a cell:

=MULTINOMIAL(1000,0)

it returns 1.

What happens instead is it returns Err:502.

More information about multinomial may be found at:
http://help.libreoffice.org/Calc/Mathematical_Functions#MULTINOMIAL
http://office.microsoft.com/en-us/excel-help/multinomial-HP005209186.aspx

Original bug at launchpad filed against 3.4, but also reproducible in master.

Changed in libreoffice (Ubuntu):
status: Triaged → Incomplete
status: Incomplete → Triaged
Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

@Kohei, Eike: Please reassign (or self-assign) as appropriate.

Also: Possible regression?

Changed in df-libreoffice:
importance: Undecided → Unknown
status: Incomplete → Unknown
Revision history for this message
In , penalvch (penalvch) wrote :

Reproducible in LibreOffice 3.3.2.

lsb_release -rd
Description: Ubuntu 10.04.3 LTS
Release: 10.04

apt-cache policy libreoffice-calc
libreoffice-calc:
  Installed: 1:3.3.2-1ubuntu2~lucid1
  Candidate: 1:3.3.2-1ubuntu2~lucid1
  Version table:
 *** 1:3.3.2-1ubuntu2~lucid1 0
        500 http://ppa.launchpad.net/libreoffice/ppa/ubuntu/ lucid/main Packages
        100 /var/lib/dpkg/status

description: updated
tags: added: lucid oneiric xubuntu
tags: added: lo33
penalvch (penalvch)
summary: - Calc: multinomial(1000,0) returns Err502 instead of 1
+ [Upstream] Calc: multinomial(1000,0) returns Err502 instead of 1
Revision history for this message
In , Markus Mohrhard (moggi) wrote :

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.

Revision history for this message
In , Markus Mohrhard (moggi) wrote :

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.

Changed in df-libreoffice:
importance: Unknown → Medium
status: Unknown → Confirmed
Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

Thanks Markus.
Adjusting importance accordingly.

Revision history for this message
In , Björn Michaelsen (bjoern-michaelsen) wrote :

Thanks Markus.
Adjusting importance accordingly.

Changed in libreoffice (Ubuntu):
importance: Medium → Wishlist
Revision history for this message
In , Bastiaan J. Braams (bjbraams) wrote :

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:

http://www.sagemath.org/doc/reference/sage/rings/arith.html#sage.rings.arith.multinomial

The associated 5-line Python code by Gabriel Ebner may be found here:

http://trac.sagemath.org/sage_trac/attachment/ticket/3132/trac3132-2.diff

I believe that this is a very natural way to compute the multinomial, and it would completely remove the problem of unnecessary overflow.

Revision history for this message
In , Bastiaan J. Braams (bjbraams) wrote :

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:

http://www.sagemath.org/doc/reference/sage/rings/arith.html#sage.rings.arith.multinomial

The associated 5-line Python code by Gabriel Ebner may be found here:

http://trac.sagemath.org/sage_trac/attachment/ticket/3132/trac3132-2.diff

I believe that this is a very natural way to compute the multinomial, and it would completely remove the problem of unnecessary overflow.

Revision history for this message
In , Markus Mohrhard (moggi) wrote :

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.

summary: - [Upstream] Calc: multinomial(1000,0) returns Err502 instead of 1
+ [Upstream] Calc: MULTINOMIAL only supports parameters up to 170
Revision history for this message
In , Markus Mohrhard (moggi) wrote :

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.

Changed in df-libreoffice:
importance: Medium → Wishlist
Revision history for this message
Bastiaan J. Braams (bjbraams) wrote :

<<Feel free to implement it.>> I appreciate the suggestion and the pointer to the code. I can see how the computation is done; a ratio of factorials indeed. However, there is a lot of code surrounding the core numerical computation that is quite mysterious to me. So, with due respect for the creators and developers of LibreOffice Calc I have to decline to touch the code myself.

Revision history for this message
In , Thuswa (thuswa) wrote :
Revision history for this message
In , Thuswa (thuswa) wrote :

Created attachment 65063
Test file to check algorithm

Revision history for this message
In , Libreoffice-bugs (libreoffice-bugs) wrote :

Albert Thuswaldner committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=1f62afae0fd04236005be70736cf7ab059a10778

fdo#43135 - fix for MULTINOMIAL only supporting parameters up to 170

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This release of Ubuntu is no longer receiving maintenance updates. If this is still an issue on a maintained version of Ubuntu please let us know.

Changed in libreoffice (Ubuntu):
status: Triaged → Incomplete
Changed in df-libreoffice:
importance: Wishlist → Unknown
status: Confirmed → Unknown
Changed in df-libreoffice:
importance: Unknown → Wishlist
status: Unknown → Fix Released
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

Synchronising bug status with upstream.

Changed in libreoffice (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.