## viewing paste CI | Haskell

Posted on the
 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 ```-- Confidence Intervals   -- Data values values = [41,40,36,26,27,37,45,47] :: [Double]   -- T-table value t = 2.13145 :: Double     -- Change the input values and *POFF* the answers appear ci :: IO () ci = do let a1 = lower mean t deviation n         let a2 = higher mean t deviation n         putStrLn ""         putStrLn \$ "N:    " ++ show n         putStrLn \$ "Mean: " ++ show mean         putStrLn \$ "Var:  " ++ show variance         putStrLn \$ "S D:  " ++ show deviation         putStrLn ""         putStrLn \$ "Low:  " ++ show a1         putStrLn \$ "High:  " ++ show a2         -- Useful functions using the data values n = fromIntegral \$ length values :: Double mean = (sum values) / n variance = sum \$ map (\x->(x-mean)^2 / (n-1)) values deviation = sqrt(variance)   -- Lower and higher functions lower :: Double -> Double -> Double -> Double -> Double lower mean tvalue deviation n = mean - ((tvalue * deviation) / (sqrt(n)))   higher :: Double -> Double -> Double -> Double -> Double higher mean tvalue deviation n = mean + ((tvalue * deviation) / (sqrt(n)))```
Viewed 414 times, submitted by unknown.