packages feed

elbow 0.1.1.0 → 0.2.0.0

raw patch · 2 files changed

+10/−10 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Math.Elbow: data MaxMin
+ Math.Elbow: data MinMax
+ Math.Elbow: instance GHC.Read.Read Math.Elbow.MinMax
+ Math.Elbow: instance GHC.Show.Show Math.Elbow.MinMax
- Math.Elbow: Max :: MaxMin
+ Math.Elbow: Max :: MinMax
- Math.Elbow: Min :: MaxMin
+ Math.Elbow: Min :: MinMax
- Math.Elbow: findElbow :: (RealFloat a, Numeric a) => MaxMin -> Matrix a -> Maybe (Int, (a, a))
+ Math.Elbow: findElbow :: (RealFloat a, Numeric a) => MinMax -> Matrix a -> Maybe (Int, (a, a))
- Math.Elbow: findElbowList :: (RealFloat a, Numeric a) => MaxMin -> [[a]] -> Maybe (Int, (a, a))
+ Math.Elbow: findElbowList :: (RealFloat a, Numeric a) => MinMax -> [[a]] -> Maybe (Int, (a, a))

Files

elbow.cabal view
@@ -1,5 +1,5 @@ name:                elbow-version:             0.1.1.0+version:             0.2.0.0 synopsis:            Find the elbow point. description:         Use rotations to identify the elbow point of a two-dimensional long-tailed distribution. homepage:            http://github.com/GregorySchwartz/elbow#readme
src/Math/Elbow.hs view
@@ -10,7 +10,7 @@   ( findElbow   , findElbowList   , getRotationAngle-  , MaxMin (..)+  , MinMax (..)   ) where  -- Remote@@ -20,7 +20,7 @@ -- Local  -data MaxMin = Max | Min+data MinMax = Min | Max deriving (Read, Show)  -- | Convert a list to a tuple. listToTuple :: [a] -> Maybe (a, a)@@ -41,18 +41,18 @@ -- (for positive x and y, top left hump would be Max, bottom right dip would be -- Min). Matrix rows are observations, columns are dimensions. findElbow :: (RealFloat a, H.Numeric a)-          => MaxMin -> H.Matrix a -> Maybe (Int, (a, a))-findElbow maxMin m = do+          => MinMax -> H.Matrix a -> Maybe (Int, (a, a))+findElbow minMax m = do   theta <- getRotationAngle m    let co = cos theta       si = sin theta       rot = (2 H.>< 2) [co, -si, si, co]       rotated = m H.<> rot-      findMaxMin Max = H.maxIndex-      findMaxMin Min = H.minIndex+      findMinMax Max = H.maxIndex+      findMinMax Min = H.minIndex -  idx <- fmap (findMaxMin maxMin) . flip atMay 1 . H.toColumns $ rotated+  idx <- fmap (findMinMax minMax) . flip atMay 1 . H.toColumns $ rotated    fmap (idx,) . listToTuple . H.toList $ m H.! idx @@ -61,5 +61,5 @@ -- (for positive x and y, top left hump would be Max, bottom right dip would be -- Min). Matrix rows are observations, columns are dimensions. List of columns. findElbowList :: (RealFloat a, H.Numeric a)-              => MaxMin -> [[a]] -> Maybe (Int, (a, a))-findElbowList maxMin = findElbow maxMin . H.fromColumns . fmap H.fromList+              => MinMax -> [[a]] -> Maybe (Int, (a, a))+findElbowList minMax = findElbow minMax . H.fromColumns . fmap H.fromList