Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Correct the use of the standard deviation argument to the log-normal procs (ticket 002b9e8e07777425) |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
56d0cf43ef74a1532221180620f2e87d |
User & Date: | arjenmarkus 2016-08-16 18:56:16 |
Context
2016-08-25
| ||
23:00 | Merged fix made to the zipfile decoder. check-in: 3a8e0f4bed user: aku tags: trunk | |
2016-08-16
| ||
18:56 | Correct the use of the standard deviation argument to the log-normal procs (ticket 002b9e8e07777425) check-in: 56d0cf43ef user: arjenmarkus tags: trunk | |
2016-08-14
| ||
07:29 | TEPAM version 0.5.2 - Fix of bug 21c45cb4c4bff37adeac400189809c7f25cea1ea - TEPAM doesn't require Tk package before using Tk commands: The updated TEPAM revision checks if Tk has been loaded prior of using Tk commands. If this is not the case an adequate error will be generated. check-in: ac49d84e58 user: droll tags: trunk | |
Changes
Changes to modules/math/ChangeLog.
1 2 3 4 5 6 7 | 2016-08-04 Arjen Markus <[email protected]> * interpolate.tcl: Correct the calculation of the weight for interpolation - cast to double * interpolate.test: Added test for this change * statistics.test: Correct the ANOVA tests (use -result) * linalg.test: Added test to show that permuted linear systems give the same result 2016-04-12 Arjen Markus <[email protected]> | > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 2016-08-16 Arjen Markus <[email protected]> * pdf_stat.tcl: Correct the use of the argument for standard deviation, affects pdf-lognormal and cdf-lognormal (ticket 002b9e8e07777425) * statistics.test: Correct the tests for both procedures * statistics.tcl: Bumped the version to 1.0.1 * pkgIndex.tcl: Load version 1.0.1 of the statistics module 2016-08-04 Arjen Markus <[email protected]> * interpolate.tcl: Correct the calculation of the weight for interpolation - cast to double * interpolate.test: Added test for this change * statistics.test: Correct the ANOVA tests (use -result) * linalg.test: Added test to show that permuted linear systems give the same result 2016-04-12 Arjen Markus <[email protected]> |
︙ | ︙ |
Changes to modules/math/pdf_stat.tcl.
︙ | ︙ | |||
82 83 84 85 86 87 88 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } | | | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } set sigma [expr {sqrt(log(1.0 + $stdev*$stdev /double($mean*$mean)))}] set mu [expr {log($mean) - 0.5 * $sigma * $sigma}] set xn [expr {(log($x)-$mu)/$sigma}] set prob [expr {exp(-$xn*$xn/2.0)/$sigma/$factorNormalPdf}] return $prob } |
︙ | ︙ | |||
199 200 201 202 203 204 205 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } | | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } set sigma [expr {sqrt(log(1.0 + $stdev*$stdev /double($mean*$mean)))}] set mu [expr {log($mean) - 0.5 * $sigma * $sigma}] set xn [expr {(log($x)-$mu)/$sigma}] set prob1 [Cdf-toms322 1 5000 [expr {$xn*$xn}]] if { $xn > 0.0 } { set prob [expr {0.5+0.5*$prob1}] } else { |
︙ | ︙ | |||
587 588 589 590 591 592 593 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } | | | 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 | if { $stdev <= 0.0 || $mean <= 0.0 } { return -code error -errorcode ARG \ -errorinfo "Standard deviation and mean must be positive" \ "Standard deviation and mean must be positive" } set sigma [expr {sqrt(log(1.0 + $stdev*$stdev /double($mean*$mean)))}] set mu [expr {log($mean) - 0.5 * $sigma * $sigma}] # set result {} # for { set i 0 } {$i < $number } { incr i } { # lappend result [Inverse-cdf-normal $mean $stdev [expr {rand()}]] # } |
︙ | ︙ |
Changes to modules/math/pkgIndex.tcl.
︙ | ︙ | |||
9 10 11 12 13 14 15 | package ifneeded math::fourier 1.0.2 [list source [file join $dir fourier.tcl]] if {![package vsatisfies [package provide Tcl] 8.3]} {return} package ifneeded math::roman 1.0 [list source [file join $dir romannumerals.tcl]] if {![package vsatisfies [package provide Tcl] 8.4]} {return} # statistics depends on linearalgebra (for multi-variate linear regression). | | | 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | package ifneeded math::fourier 1.0.2 [list source [file join $dir fourier.tcl]] if {![package vsatisfies [package provide Tcl] 8.3]} {return} package ifneeded math::roman 1.0 [list source [file join $dir romannumerals.tcl]] if {![package vsatisfies [package provide Tcl] 8.4]} {return} # statistics depends on linearalgebra (for multi-variate linear regression). package ifneeded math::statistics 1.0.1 [list source [file join $dir statistics.tcl]] package ifneeded math::optimize 1.0.1 [list source [file join $dir optimize.tcl]] package ifneeded math::calculus 0.8.1 [list source [file join $dir calculus.tcl]] package ifneeded math::interpolate 1.1.1 [list source [file join $dir interpolate.tcl]] package ifneeded math::linearalgebra 1.1.5 [list source [file join $dir linalg.tcl]] package ifneeded math::bignum 3.1.1 [list source [file join $dir bignum.tcl]] package ifneeded math::bigfloat 1.2.2 [list source [file join $dir bigfloat.tcl]] package ifneeded math::machineparameters 0.1 [list source [file join $dir machineparameters.tcl]] |
︙ | ︙ |
Changes to modules/math/statistics.man.
︙ | ︙ | |||
43 44 45 46 47 48 49 50 51 52 53 54 55 56 | can be distinguished in three sets: general procedures, procedures that deal with specific statistical distributions, list procedures to select or transform data and simple plotting procedures (these require Tk). [emph Note:] The data that need to be analyzed are always contained in a simple list. Missing values are represented as empty list elements. [section "GENERAL PROCEDURES"] The general statistical procedures are: [list_begin definitions] [call [cmd ::math::statistics::mean] [arg data]] | > > > > > | 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | can be distinguished in three sets: general procedures, procedures that deal with specific statistical distributions, list procedures to select or transform data and simple plotting procedures (these require Tk). [emph Note:] The data that need to be analyzed are always contained in a simple list. Missing values are represented as empty list elements. [emph Note:] With version 1.0.1 a mistake in the procs [term pdf-lognormal], [term cdf-lognormal] and [random-lognormal] has been corrected. In previous versions the argument for the standard deviation was actually used as if it was the variance. [section "GENERAL PROCEDURES"] The general statistical procedures are: [list_begin definitions] [call [cmd ::math::statistics::mean] [arg data]] |
︙ | ︙ |
Changes to modules/math/statistics.tcl.
︙ | ︙ | |||
15 16 17 18 19 20 21 22 23 | # version 0.6: added pdf and cdf procedures for various distributions # (provided by Eric Kemp-Benedict) # version 0.7: added Kruskal-Wallis test (by Torsten Berg) # version 0.8: added Wilcoxon test and Spearman rank correlation # version 0.9: added kernel density estimation # version 0.9.3: added histogram-alt, corrected test-normal # version 1.0: added test-anova-F package require Tcl 8.4 | > | | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # version 0.6: added pdf and cdf procedures for various distributions # (provided by Eric Kemp-Benedict) # version 0.7: added Kruskal-Wallis test (by Torsten Berg) # version 0.8: added Wilcoxon test and Spearman rank correlation # version 0.9: added kernel density estimation # version 0.9.3: added histogram-alt, corrected test-normal # version 1.0: added test-anova-F # version 1.0.1: correction in pdf-lognormal and cdf-lognormal package require Tcl 8.4 package provide math::statistics 1.0.1 package require math if {![llength [info commands ::lrepeat]]} { # Forward portability, emulate lrepeat proc ::lrepeat {n args} { if {$n < 1} { return -code error "must have a count of at least 1" |
︙ | ︙ |
Changes to modules/math/statistics.test.
︙ | ︙ | |||
566 567 568 569 570 571 572 573 574 575 576 | [::math::statistics::cdf-normal 0 1 1] \ [::math::statistics::cdf-normal 0.0 1.0 1.0] \ [::math::statistics::cdf-normal 2.0 2.0 4.0] \ [::math::statistics::cdf-normal -2.0 2.0 0.0] \ [::math::statistics::cdf-normal 2.0 2.0 3.0]] } -result {0.8413205502059895 0.8413205502059895 0.8413205502059895 0.8413205502059895 0.691451459572962} test "lognormal-distribution-1.0" "Test pdf-lognormal" -match tolerant -body { foreach {mu sigma mean stdev} {0.0 1.0 mean1 stdev1 2.0 2.0 mean2 stdev2 -2.0 2.0 mean3 stdev3} { set m [expr {exp($mu + $sigma*$sigma/2.0)}] set $mean $m | > > > > | | | 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | [::math::statistics::cdf-normal 0 1 1] \ [::math::statistics::cdf-normal 0.0 1.0 1.0] \ [::math::statistics::cdf-normal 2.0 2.0 4.0] \ [::math::statistics::cdf-normal -2.0 2.0 0.0] \ [::math::statistics::cdf-normal 2.0 2.0 3.0]] } -result {0.8413205502059895 0.8413205502059895 0.8413205502059895 0.8413205502059895 0.691451459572962} # # The values of the mean and the standard deviation are reconstructed from mu and sigma. # If you use mu and sigma in pdf-normal/cdf-normal, the same numbers should arise # test "lognormal-distribution-1.0" "Test pdf-lognormal" -match tolerant -body { foreach {mu sigma mean stdev} {0.0 1.0 mean1 stdev1 2.0 2.0 mean2 stdev2 -2.0 2.0 mean3 stdev3} { set m [expr {exp($mu + $sigma*$sigma/2.0)}] set $mean $m set $stdev [expr {sqrt(exp($sigma*$sigma) - 1.0) * $m}] } set x [list \ [::math::statistics::pdf-lognormal $mean1 $stdev1 [expr {exp(1.0)}]] \ [::math::statistics::pdf-lognormal $mean2 $stdev2 [expr {exp(4.0)}]] \ [::math::statistics::pdf-lognormal $mean3 $stdev3 [expr {exp(0.0)}]] \ [::math::statistics::pdf-lognormal $mean2 $stdev2 [expr {exp(3.0)}]]] } -result {0.24197072451914337 0.12098536225957168 0.12098536225957168 0.17603266338214976} test "lognormal-distribution-1.1" "Test cdf-lognormal" -match tolerant -body { foreach {mu sigma mean stdev} {0.0 1.0 mean1 stdev1 2.0 2.0 mean2 stdev2 -2.0 2.0 mean3 stdev3} { set m [expr {exp($mu + $sigma*$sigma/2.0)}] set $mean $m set $stdev [expr {sqrt(exp($sigma*$sigma) - 1.0) * $m}] } set x [list \ [::math::statistics::cdf-lognormal $mean1 $stdev1 [expr {exp(1.0)}]] \ [::math::statistics::cdf-lognormal $mean2 $stdev2 [expr {exp(4.0)}]] \ [::math::statistics::cdf-lognormal $mean3 $stdev3 [expr {exp(0.0)}]] \ [::math::statistics::cdf-lognormal $mean2 $stdev2 [expr {exp(3.0)}]]] |
︙ | ︙ |