login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Testing Martin's statistics code

axiom
)abbrev package STAT StatisticalFunctions
StatisticalFunctions(F:Field): Exports == Implementation where
Exports == with mean: List F -> F
stddev: List F -> F
if F has OrderedRing then median: List F -> F
Implementation == add
mean l == n := #l::F if n = 0 then error "The mean of an empty list is not defined" reduce(_+, l)/n
stddev l == n := #l::F if n = 0 then error "The standard deviation of an empty list is not _ defined"
m := mean l reduce(_+, map((#1-m)**2, l)$ListFunctions2(F,F))/(n-1)
if F has OrderedRing then median l == n := #l if n = 0 then error "The median of an empty list is not defined" sort(l).(n quo 2)
axiom
Compiling FriCAS source code from file 
      /var/zope2/var/LatexWiki/4372653822899247572-25px.001.spad using 
      old system compiler.
   STAT abbreviates package StatisticalFunctions 
------------------------------------------------------------------------
   initializing NRLIB STAT for StatisticalFunctions 
   compiling into NRLIB STAT 
   compiling exported mean : List F -> F
Time: 0.23 SEC.
compiling exported stddev : List F -> F ****** comp fails at level 9 with expression: ****** error in function stddev
(SEQ (LET |n| (|::| (|#| |l|) F)) (IF (= |n| 0) (|error| "The standard deviation of an empty list is not defined") |noBranch|) (LET |m| (|mean| |l|)) (|exit| 1 (/ (|reduce| + ((|elt| (|ListFunctions2| F F) |map|) (** (- |#1| |m|) 2) |l|)) (- |n| 1)))) ****** level 9 ****** $x:= (** (- #1 m) 2) $m:= F $f:= ((((|#1| #) (|m| #) (|n| #) (|last| #) ...)))
>> Apparent user error: no mode found for #1

axiom
mean [1,2,3]

\label{eq1}mean_{1, \: 2, \: 3}(1)
Type: Symbol

is it possible to change the package --unknown, Tue, 26 Jul 2005 05:15:09 -0500 reply
axiom
median (["a","g","u","a","d"])

\label{eq2}median_{\mbox{\tt "a"}, \: \mbox{\tt "g"}, \: \mbox{\tt "u"}, \: \mbox{\tt "a"}, \: \mbox{\tt "d"}}(2)
Type: Symbol




  Subject:   Be Bold !!
  ( 7 subscribers )  
Please rate this page: