wrong result of var() function (update documentation)

Bug #404001 reported by zacek
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenOffice
Invalid
Undecided
Unassigned
openoffice.org (Ubuntu)
Invalid
Low
Unassigned

Bug Description

Binary package hint: openoffice.org

The var() function calculates wrong result, e.g. for the set 5,5,5,5,10 the correct variance is 4 but the function returns 5. See http://en.wikipedia.org/wiki/Variance

ProblemType: Bug
Architecture: amd64
DistroRelease: Ubuntu 9.04
NonfreeKernelModules: nvidia
Package: openoffice.org-core 1:3.0.1-9ubuntu3
ProcEnviron:
 PATH=(custom, no user)
 LANG=cs_CZ.UTF-8
 SHELL=/bin/bash
SourcePackage: openoffice.org
Uname: Linux 2.6.28-11-generic x86_64

Revision history for this message
zacek (miroslav-zacek) wrote :
Revision history for this message
Thomas Skardal (tskardal) wrote :

Are you _sure_ about this? WolforamAlpha disagrees :-)

http://www78.wolframalpha.com/input/?i=variance+5%2C5%2C5%2C5%2C10

Changed in openoffice.org (Ubuntu):
status: New → Invalid
Changed in openoffice.org (Ubuntu):
status: Invalid → Incomplete
Revision history for this message
zacek (miroslav-zacek) wrote :

Maple gives also 4. I've computed the variance from definition and it is really 4 :-)

x_avg = average( x ) = 6

var(X) = average( x - x_avg)^2 ) = ( 1 + 1 + 1 + 1 + 4*4 ) / 5 = 20 / 5 = 4

var(X) = average( x^2 ) - average(x) ^ 2 = ( 5^2 + 5^2 + 5^2 + 5^2 + 10^2 ) / 5 - 6^2 = 200/5 - 36 = 4

The problem is that you calculate the biased corrected sample variance instead of sample variance. See the form (5) and read the article that follows this equation in http://mathworld.wolfram.com/Variance.html. WolframAlpha implements the biased corrected version a variance, Maple the not corrected version. I've tested it in Excel and it gives also the corrected version (i.e. 5). You should probably at least give some note to the help of the function list to avoid such confusion.

Chris Cheney (ccheney)
Changed in openoffice.org (Ubuntu):
importance: Undecided → Low
status: Incomplete → Triaged
summary: - wrong result of var() function
+ [upstream] wrong result of var() function (update documentation)
Chris Cheney (ccheney)
tags: added: jaunty
penalvch (penalvch)
summary: - [upstream] wrong result of var() function (update documentation)
+ wrong result of var() function (update documentation)
Changed in openoffice.org (Ubuntu):
status: Triaged → Won't Fix
Revision history for this message
Björn Michaelsen (bjoern-michaelsen) wrote : migrating packaging from OpenOffice.org to Libreoffice

[This is an automated message.]
There are no new official OpenOffice.org releases in Ubuntu packaging anymore => Won't Fix

If the problem persists, please mark this bug as "also affects project Libreoffice" or "also affects distribution Libreoffice (Ubuntu)" if that has not happened already.

Please leave references to upstream OpenOffice.org bugs in place to allow cross pollination.

Revision history for this message
penalvch (penalvch) wrote :

No upstream URL.

Changed in openoffice:
status: New → Invalid
Revision history for this message
penalvch (penalvch) wrote :

zacek, regarding the VAR function, OOo and LibreOffice both return 5 in order to keep compatibility with Excel, and matches the definition of a population sample variance from Wikipedia via OOo documentation:

http://wiki.services.openoffice.org/wiki/Documentation/How_Tos/Calc:_VAR_function

Feel free to report any future bugs you may find.

Changed in openoffice.org (Ubuntu):
status: Won't Fix → Invalid
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.