Created
December 13, 2012 16:39
-
-
Save aprell/4277768 to your computer and use it in GitHub Desktop.
Simple script to calculate the standard deviation of a series of numbers (Bash, Io)
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
#!/bin/bash | |
# Calculate the standard deviation of a series of numbers | |
cat > stddev.io <<IOCODE | |
#!/usr/bin/env io | |
l := List clone | |
IOCODE | |
chmod +x stddev.io | |
while read number; do | |
echo $number | |
cat >> stddev.io <<IOCODE | |
l append($number) | |
IOCODE | |
done | |
cat >> stddev.io <<IOCODE | |
((l map(x, (x - l average) squared) sum) / (l size - 1)) sqrt println | |
IOCODE | |
echo "====================" | |
echo " Standard deviation " | |
echo "====================" | |
echo "scale=2; $(io stddev.io)/1" | bc | |
rm stddev.io |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment