librarylib/Stats.xtl

Stats: a small statistics library (a standard library, built into xetal). Import it with an alias of your choice: "s:" u_se< "Stats". It is a demo library, loaded only by that import: a small subset of X_eTaL-libraries' Statistics, which has much more (a program may use either). Names with l: are exported; the others are private to this file.

source

ˡm̲ean : Num a => a -> Float

function · line 12

The arithmetic mean, of Int or Float numbers.

      ˢ⁼u̲se< "Stats"
      ˢm̲ean 2 4 4 4 5 5 7 9
5.0
ˡm̲ean ← [[f̲loat '+ r̲/] ÷ [f̲loat t̲ally]]

s̲quare : Num a => a -> a

function (private) · line 14
s̲quare ← { ⍵ × ⍵ }                      ⍝ private: not visible outside
Used in: ˡv̲ariance

d̲eviations : Num a => a -> Float

function (private) · line 15
d̲eviations ← [f̲loat − ˡm̲ean]
Used in: ˡv̲ariance

ˡv̲ariance : Num a => a -> Float

function · line 21

The variance: the mean squared deviation from the mean.

      ˢ⁼u̲se< "Stats"
      ˢv̲ariance 2 4 4 4 5 5 7 9
4.0
ˡv̲ariance ← [ˡm̲ean [s̲quare d̲eviations]]
Used in: ˡs̲d

ˡs̲d : Num a => a -> Float

function · line 27

The standard deviation: the square root of the variance.

      ˢ⁼u̲se< "Stats"
      ˢs̲d 2 4 4 4 5 5 7 9
2.0
ˡs̲d ← { (ˡv̲ariance ⍵) ^ 0.5 }

ˡr̲ange : Num a => a -> a

function · line 33

The range: the largest minus the smallest.

      ˢ⁼u̲se< "Stats"
      ˢr̲ange 2 4 4 4 5 5 7 9
7
ˡr̲ange ← ['m̲ax r̲/ − 'm̲in r̲/]