Changes 
http://page.axiom-developer.org/zope/mathaction/StatisticalFunctions/diff
--
I just started to hack together a couple of statistical functions. Should be 
extended of course. The median could be implemented in 'O(n)' steps, but I 
don't have the time.

\begin{axiom}
)abb 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)
\end{axiom}
--
forwarded from http://page.axiom-developer.org/zope/mathaction/[EMAIL PROTECTED]


_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to