Testing Martin's statistics code
(1) -> )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)
Compiling FriCAS source code from file /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7576195002424551243-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.02 SEC.
compiling exported stddev : List F -> F Time: 0 SEC.
****** Domain: F already in scope augmenting F: (OrderedRing) compiling exported median : List F -> F Time: 0 SEC.
****** Domain: F already in scope augmenting F: (OrderedRing) (time taken in buildFunctor: 0) Time: 0 SEC.
Cumulative Statistics for Constructor StatisticalFunctions Time: 0.03 seconds
finalizing NRLIB STAT Processing StatisticalFunctions for Browser database: --->-->StatisticalFunctions(constructor): Not documented!!!! --->-->StatisticalFunctions((mean (F (List F)))): Not documented!!!! --->-->StatisticalFunctions((stddev (F (List F)))): Not documented!!!! --->-->StatisticalFunctions((median (F (List F)))): Not documented!!!! --->-->StatisticalFunctions(): Missing Description ; compiling file "/var/aw/var/LatexWiki/STAT.NRLIB/STAT.lsp" (written 14 OCT 2025 07:33:39 AM):
; wrote /var/aw/var/LatexWiki/STAT.NRLIB/STAT.fasl ; compilation finished in 0:00:00.012 ------------------------------------------------------------------------ StatisticalFunctions is now explicitly exposed in frame initial StatisticalFunctions will be automatically loaded when needed from /var/aw/var/LatexWiki/STAT.NRLIB/STAT
mean [1,2, 3]
median (["a","g", "u", "a", "d"])