Skip to content

Instantly share code, notes, and snippets.

@bonipart
Created February 11, 2012 16:01
Show Gist options
  • Save bonipart/1801360 to your computer and use it in GitHub Desktop.
Save bonipart/1801360 to your computer and use it in GitHub Desktop.
Problem 2 of 3, embed.ly challenge
--list of <p> tag depths
ps = [1,2,1,1,1,1,1,1,1,2,2,2,3,3,3,4,4,4,4,4,5,5,5,5,1,1,1,1,1,2,1,1,1,1,2,2,1,3,1]
--compute mean of data points
avg = x/y
where
x = sum ps
y = fromIntegral(length ps)
--computes difference of data point and mean, square the result
diffSq p = (p - avg)^2
--computes the std divation by taking the average of diffSq results, then taking the sqrt
stdiv = sqrt(x/y)
where
x = sum (map diffSq ps)
y = fromIntegral(length ps)
main = putStrLn (show stdiv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment