Tcl Library Source Code

Check-in [55e0ff7a50]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Correct the tests for the ANOVA procedure and the comments regarding the purpose of ANOVA
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 55e0ff7a50535e4bd17434db5ffaa633f24a19a8
User & Date: arjenmarkus 2017-01-09 20:18:02
Context
2017-01-09
23:57
Module uri. Amend code and tests for full RFC 3986 compliance (except the RFC 1630 loophole). Add quirk options to permit non-compliant behavior, including for backward compatibility. Accept and amend certain invalid arguments instead of throwing an error. Test uri::split and uri::join both with and without the quirk "NoInitialSlash" (leading "/" in path for schemes http(s), ftp). Update uri.man. check-in: 0b8557b27d user: kjnash tags: trunk
20:18
Correct the tests for the ANOVA procedure and the comments regarding the purpose of ANOVA check-in: 55e0ff7a50 user: arjenmarkus tags: trunk
2017-01-08
10:06
Correct several tests in the math module - they were failing in Tcl 8.5, seemingly not in Tcl 8.6. After these corrections there are still two tests left that need examination, both concerning test-anova-F in the statistics package. check-in: d535d2f0ea user: arjenmarkus tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to modules/math/TODO.

1
2



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
This file records outstanding actions for the math module





dd. 3 august 2016
- Fix problem in interpolation - integer arguments - done
- Fix problem in pdf-lognormal and cdf-lognormal: stdev is now used as variance

dd. 4 august 2016
- Add test case for permuted linear system
- Add test case for pdf-lognormal and cdf-lognormal (non-unity standard deviation)



dd. 11 april 2016
Fix problem in math::geometry::pointInsidePolygon (Eduard on comp.lang.tcl):

% set polygon "-764 -677 -668 -1341 -124 -797 -508 -406"


>
>
>



|


|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
This file records outstanding actions for the math module

dd. 8 january 2017
- Fix problem with test-anova-F (at least the test cases 1.1 and 1.2)


dd. 3 august 2016
- Fix problem in interpolation - integer arguments - done
- Fix problem in pdf-lognormal and cdf-lognormal: stdev is now used as variance - done

dd. 4 august 2016
- Add test case for permuted linear system - done
- Add test case for pdf-lognormal and cdf-lognormal (non-unity standard deviation) - done



dd. 11 april 2016
Fix problem in math::geometry::pointInsidePolygon (Eduard on comp.lang.tcl):

% set polygon "-764 -677 -668 -1341 -124 -797 -508 -406"

Changes to modules/math/statistics.tcl.

1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
             return -code error "Significance level must be 0.05, 0.01 or 0.001"
        }
    }
}

# test-anova-F --
#     Check if two or more groups with normally distributed data have the same
#     variances
#
# Arguments:
#     alpha            Significance level
#     args             One or more lists containing the data for the
#                      other groups
#
# Returns:
#     Whether the variation for the groups is likely to be the same (1)
#     or not (0).
#
# Note:
#     args may be a nested list
#
#     Implementation based on Wikipedia page on the F-test, one-way ANOVA
#
#     Possibly of interest: the ratio itself.
#
proc test-anova-F {alpha args} {
    if { [llength $args] == 1 } {
        set args [lindex $args 0]
    }

    if { [llength $args] < 2 } {
        return -code error -errorcode ARG -errorinfo "At least two groups are required" \
                                                     "At least two groups are required"







|







|









|







1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
             return -code error "Significance level must be 0.05, 0.01 or 0.001"
        }
    }
}

# test-anova-F --
#     Check if two or more groups with normally distributed data have the same
#     means
#
# Arguments:
#     alpha            Significance level
#     args             One or more lists containing the data for the
#                      other groups
#
# Returns:
#     Whether the mean for the groups is likely to be the same (1)
#     or not (0).
#
# Note:
#     args may be a nested list
#
#     Implementation based on Wikipedia page on the F-test, one-way ANOVA
#
#     Possibly of interest: the ratio itself.
#
proc ::math::statistics::test-anova-F {alpha args} {
    if { [llength $args] == 1 } {
        set args [lindex $args 0]
    }

    if { [llength $args] < 2 } {
        return -code error -errorcode ARG -errorinfo "At least two groups are required" \
                                                     "At least two groups are required"

Changes to modules/math/statistics.test.

1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
        set sum [expr {$sum + $dx * $v}]
    }

    return [expr {abs($sum-1.0) < 0.01}]
} -result 1

test "anova-one-way-1.1" "ANOVA test from Wikipedia" -body {
    test-anova-F 0.05 {6 8 4 5 3 4} {8 12 9 11 6 8} {13 9 11 8 7 12}
} -result 1

test "anova-one-way-1.2" "ANOVA test from Wikipedia - using nested list" -body {
    test-anova-F 0.05 {{6 8 4 5 3 4} {8 12 9 11 6 8} {13 9 11 8 7 12}}
} -result 1

# End of test cases
testsuiteCleanup







|
|


|
|



1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
        set sum [expr {$sum + $dx * $v}]
    }

    return [expr {abs($sum-1.0) < 0.01}]
} -result 1

test "anova-one-way-1.1" "ANOVA test from Wikipedia" -body {
    ::math::statistics::test-anova-F 0.05 {6 8 4 5 3 4} {8 12 9 11 6 8} {13 9 11 8 7 12}
} -result 0

test "anova-one-way-1.2" "ANOVA test from Wikipedia - using nested list" -body {
    ::math::statistics::test-anova-F 0.05 {{6 8 4 5 3 4} {8 12 9 11 6 8} {13 9 11 8 7 12}}
} -result 0

# End of test cases
testsuiteCleanup