rank-product 0.1.0.5 → 0.2.0.1
raw patch · 3 files changed
+23/−16 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Statistics.Types: Ascending :: Sort
+ Statistics.Types: Descending :: Sort
+ Statistics.Types: data Sort
+ Statistics.Types: instance GHC.Classes.Eq Statistics.Types.Sort
+ Statistics.Types: instance GHC.Classes.Ord Statistics.Types.Sort
+ Statistics.Types: instance GHC.Read.Read Statistics.Types.Sort
+ Statistics.Types: instance GHC.Show.Show Statistics.Types.Sort
- Statistics.RankProduct: rankList :: (Ord a) => [a] -> [Double]
+ Statistics.RankProduct: rankList :: (Ord a) => Sort -> [a] -> [Double]
- Statistics.RankProduct: rankProduct :: [Entity] -> [RankProductEntity]
+ Statistics.RankProduct: rankProduct :: Sort -> [Entity] -> [RankProductEntity]
- Statistics.RankProduct: rankProductPermutation :: Permutations -> [Entity] -> IO [(RankProductEntity, PValue)]
+ Statistics.RankProduct: rankProductPermutation :: Permutations -> Sort -> [Entity] -> IO [(RankProductEntity, PValue)]
Files
- rank-product.cabal +1/−1
- src/Statistics/RankProduct.hs +21/−15
- src/Statistics/Types.hs +1/−0
rank-product.cabal view
@@ -1,5 +1,5 @@ name: rank-product-version: 0.1.0.5+version: 0.2.0.1 synopsis: Find the rank product of a data set. description: Find the rank product of a data set and get the p-value from a permutation test. homepage: http://github.com/GregorySchwartz/rank-product#readme
src/Statistics/RankProduct.hs view
@@ -18,31 +18,35 @@ import Data.Function (on) import Data.List import Data.Random-import Debug.Trace- + -- Cabal -- Local import Statistics.Types -- | Rank transform a list.-rankList :: (Ord a) => [a] -> [Double]-rankList = fmap fst- . sortBy (compare `on` (fst . snd))- . zip [1..]- . sortBy (compare `on` snd)- . zip [1..]+rankList :: (Ord a) => Sort -> [a] -> [Double]+rankList sortType = fmap fst+ . sortBy (compare `on` (fst . snd))+ . rankType sortType+ . zip [1..]+ . sortBy (compare `on` snd)+ . zip [1..]+ where+ rankType Ascending = id+ rankType Descending = (\(!xs, !ys) -> zip (reverse xs) ys) . unzip --- | Get the rank product of a list of Entity.-rankProduct :: [Entity] -> [RankProductEntity]-rankProduct xs =+-- | Get the rank product of a list of Entity. Ascending ranks the lowest value+-- as 1 while Descending ranks the highest value as 1.+rankProduct :: Sort -> [Entity] -> [RankProductEntity]+rankProduct sortType xs = fmap ( RankProductEntity . (** (1 / (genericLength . unEntity . head $ xs))) . product ) . transpose- . fmap rankList+ . fmap (rankList sortType) . transpose . fmap unEntity $ xs@@ -72,14 +76,16 @@ boolToNum True = 1 -- | Get the rank product of a list of Entity as well as the permutation--- p-value.+-- p-value. Ascending ranks the lowest value as 1 while Descending ranks the+-- highest value as 1. rankProductPermutation :: Permutations+ -> Sort -> [Entity] -> IO [(RankProductEntity, PValue)]-rankProductPermutation (Permutations permutations) entities = do+rankProductPermutation (Permutations permutations) sortType entities = do let ranked = fmap RankEntity . transpose- . fmap rankList+ . fmap (rankList sortType) . transpose . fmap unEntity $ entities
src/Statistics/Types.hs view
@@ -23,3 +23,4 @@ newtype PValue = PValue { unPValue :: Double } deriving (Show) -- Advanced+data Sort = Ascending | Descending deriving (Eq, Ord, Read, Show)