inhomoSum :: RealFloat a => [a] -> a
inhomoSum xs
= sum [ ((s1 n)**2 + (s2 n)**2) / n**2
| i <- [1..huge], n <- [fromIntegral i] ]
where
s1 n = sum [ cos (2 * pi * n * x) | x <- xs ]
s2 n = sum [ sin (2 * pi * n * x) | x <- xs ]
huge = 1000
inhomoSignificance :: RealFloat a => [a] -> a
inhomoSignificance xs
| xs == [] = error "inhomoSignificance undefined for empty list"
| otherwise = prob (inhomoSum xs / count)
where
count = fromIntegral (length xs)
prob x = limit (
sum [ (if i < huge then 2 else 1) *
(-1)**(n-1) * exp (-n**2 * x)
| i <- [1..huge], n <- [fromIntegral i] ]
)
limit = (min 1 . max 0)
huge = 1000
inhomogeneity :: RealFloat a => [a] -> a
inhomogeneity xs
| xs == [] = error "inhomogenity undefined for empty list"
| length xs == 1 = error "inhomogenity undefined for single value"
| otherwise = sqrt ( limit (
(inhomoSum xs * 6 / pi**2 - 1) /
(count**2 - 1)
) )
where
count = fromIntegral (length xs)
limit = max 0