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.
Center
ʰs̲quare : Num a => a -> a
Each number times itself.
ʰs̲quare ← { ⍵ × ⍵ } ⍝ private: not visible outside
Used in: ˡv̲ariance
ʰd̲eviations : Num a => a -> Float
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
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
ˡs̲d ← { (ˡv̲ariance ⍵) ^ 0.5 }