| Ticket UUID: | 820807 | |||
| Title: | Bug in ::math::statistics::mean ? | |||
| Type: | Bug | Version: | None | |
| Submitter: | woj | Created on: | 2003-10-09 18:39:55 | |
| Subsystem: | math | Assigned To: | arjenmarkus | |
| Priority: | 7 High | Severity: | ||
| Status: | Closed | Last Modified: | 2003-11-21 12:47:37 | |
| Resolution: | Fixed | Closed By: | andreas_kupries | |
| Closed on: | 2003-11-21 05:47:37 | |||
| Description: |
I am running math version 1.2.2 and statistics version0.06. The following line of code: ::math::statistics::mean "0.06 0.06 0.06 0.06 0.06 0.06 0.06 0.06" returns error: domain error: argument not in valid range After reducing the number of elements from 8 to 7, the bug no longer shows up. Thanks. | |||
| User Comments: |
andreas_kupries added on 2003-11-21 12:47:37:
Logged In: YES user_id=75003 No response for nearly a month. Considering this as closed. Set to auto-close if no further response within 7 days. arjenmarkus added on 2003-10-30 14:59:01: Logged In: YES user_id=400048 Just committed the patches. Can you let me know that this is indeed working? Then we can close the bug report arjenmarkus added on 2003-10-23 14:12:26: Logged In: YES
user_id=400048
Yes, this is a bug: the problem is that the data are
identical numbers. That becomes a problem in the
determination of the variance (all basic statistical
parameters are calculated, even with the mean proc):
sometimes the result is a very small negative number and
then taking the square root causes a domain error.
The solution is to add the following lines:
if { $var < 0.0 } {
set var 0.0
}
in the if-block where the variance is determined (proc
BasicStats).
This is the corrected fragment:
if { $number > 1 } {
set var [expr
{($sumsq-$mean*$sum)/double($number-1)}]
#
# Take care of a rare situation: uniform data might
# cause a tiny negative difference
#
if { $var < 0.0 } {
set var 0.0
}
set stdev [expr {sqrt($var)}]
}
I will submit an updated version plus an updated test script
later
| |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki