sourcedemos/stats.xtl

1⍝!/usr/bin/env xetal 2⍝# Using a library: Stats is a standard library, built into xetal 3⍝# (lib/Stats.xtl). The alias "s:" is this file's name for it: its 4⍝# exported names are used as s:m_ean and so on. 5⍝# 6⍝# Run it with ./demos/stats.xtl or "xetal run demos/stats.xtl". It 7⍝# prints the mean, variance, standard deviation and range of v, then 8⍝# a mean of Floats; the expected values are in the comments. 9 10ˢ⁼u̲se< "Stats" 11 12⍝# The sample: eight Ints with mean 5 and standard deviation 2. 13v ← 2 4 4 4 5 5 7 9 14ˢm̲ean v ⍝ 5.0 15ˢv̲ariance v ⍝ the mean squared deviation: 4.0 16ˢs̲d v ⍝ the standard deviation: 2.0 17ˢr̲ange v ⍝ largest minus smallest: 7 18ˢm̲ean 1.5 2.5 ⍝ the same functions work on Floats