Created
August 14, 2014 05:02
-
-
Save evincarofautumn/3c2309e7941751573eb4 to your computer and use it in GitHub Desktop.
Statistical manipulations in Kitten.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// “μσ” calculates the mean and standard deviation of a list, given the sum of the squares of the elements, the sum of the elements, and the reciprocal of the length. Uses real characters for more mathiness. | |
// With local variables, in infix: | |
def μσ (float float float → float float): | |
→ ss s in; | |
s ×. in → μ; | |
(ss ×. in −. μ sq) sqrt → σ; | |
μ σ | |
// With local variables, in postfix: | |
def μσ (float float float → float float): | |
→ ss s in; | |
s in (×.) → μ; | |
ss in (×.) μ sq (−.) sqrt → σ; | |
μ σ | |
// Eliminating σ: | |
def μσ (float float float → float float): | |
→ ss s in; | |
s in (×.) → μ; | |
μ | |
ss in (×.) μ sq (−.) sqrt | |
// Eliminating μ: | |
def μσ (float float float → float float): | |
→ ss s in; | |
s in (×.) dup | |
{ ss in (×.) } dip | |
sq (−.) sqrt | |
// Auxiliary definitions: | |
def sq (float → float): dup (×.) | |
def sqrt (float → float): … |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment