librarystd/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; names with h: are private to this file.

source

Center

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

function · line 14

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 17

Each number times itself.

ʰs̲quare ← { ⍵ × ⍵ }                       ⍝ private: not visible outside
Used in: ˡv̲ariance

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

function (private) · line 19

How far each number is from the mean, as Floats.

ʰd̲eviations ← [f̲loat − ˡm̲ean]
Used in: ˡv̲ariance

Spread

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

function · line 27

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 33

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 39

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̲/]