aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/cluster.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/cluster.hs b/bin/cluster.hs
index 4d67541..dd8f2c6 100644
--- a/bin/cluster.hs
+++ b/bin/cluster.hs
@@ -7,6 +7,7 @@ import Data.Fixed (mod')
import Data.Foldable (toList)
import Data.List
import qualified Data.Map as M
+import GHC.Compact
import Numeric.Log hiding (sum)
import Options.Applicative
import PPL
@@ -94,7 +95,7 @@ drawGraph path ps cl = writeFile path $ "digraph{" <> edges <> "}"
-- Normalise to frequency of parent
norm :: [Double] -> [Double]
- norm xxs@(x : xs) = x : zipWith (\i y -> y / xxs !! parent i) [1..] xs
+ norm xxs@(x : xs) = x : zipWith (\i y -> y / xxs !! parent i) [1 ..] xs
-- Command line args
data Options = Options
@@ -129,9 +130,9 @@ main = run =<< execParser opts
run opts = do
setStdGen . mkStdGen $ seed opts
(hdr : lines) <- lines <$> readFile (input opts)
- let parsed = map (map dbl . tail . words) lines
- dbl = round . read :: String -> Int
- ((ps, cl), _) <- foldl1' (\a c -> if mml a < mml c then a else c) . take (nsamples opts) <$> mh (mhfrac opts) (model parsed)
+ let dbl = round . read :: String -> Int
+ parsed <- compact $ map (map dbl . tail . words) lines
+ ((ps, cl), _) <- foldl1' (\a c -> if mml a < mml c then a else c) . take (nsamples opts) <$> mh (mhfrac opts) (model $ getCompact parsed)
writeFile (propsPath opts) . unlines $ map (intercalate "," . map show) ps
writeFile (clusterPath opts) . unlines $ map show cl
when (dotPath opts /= "") $ drawGraph (dotPath opts) ps cl