packages feed

Persistence 1.1.3 → 1.1.4

raw patch · 3 files changed

+31/−26 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

ChangeLog.md view
@@ -12,10 +12,18 @@ - A function for encoding generic graphs as 2D vectors.  ### Changed-- Improved documentation for all exposed modules.+- Improved documentation for all exposed modules.      -## 1.1.3  -- 2018-07-30+## 1.1.3 -- 2018-07-30  ### Changed+ - Fixed a major bug with persistent homology; high dimensional holes were being detected in low dimensional data sets. - Persistent homology now filters out bar codes of the form (i, Just i), as they say nothing about the topology of the underlying complexes.++## 1.1.4 -- 2018-09-15++### Changed++- Fixed spelling error.+- Persistence now exports the constructors for `Extended a`.
Persistence.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                Persistence-version:             1.1.3+version:             1.1.4 synopsis:            Quickly detect clusters and holes in data. description:         Persistence is a topological data analysis library motivated by flexibility when it comes to the type of data being analyzed. If you have data that comes with a meaningful function into something of the Ord typeclass, you can use Persistence to detect clusters and holes in the data. You can also use the library to analyze the topology of directed\/undirected weighted\/unweighted graphs, and compare topologies of different data sets. license:             BSD3@@ -19,6 +19,6 @@   exposed-modules:     SimplicialComplex, HasseDiagram, Persistence   other-modules:       Util, Matrix   -- other-extensions:    -  build-depends:       base >=4.9 && <4.11.2, vector >=0.12 && <0.13, parallel >=3.2 && <3.3, containers >=0.5 && <0.6, maximal-cliques >=0.1 && <0.2+  build-depends:       base >=4.9 && <4.12, vector >=0.12 && <0.13, parallel >=3.2 && <3.3, containers >=0.5 && <0.6, maximal-cliques >=0.1 && <0.2   -- hs-source-dirs:         default-language:    Haskell2010
Persistence.hs view
@@ -24,7 +24,7 @@ module Persistence   ( Filtration   , BarCode-  , Extended+  , Extended (Finite, Infinity)   , sim2String   , filtr2String   , getComplex@@ -150,9 +150,7 @@           if V.null simplices then simplices           else mapWithIndex (\i ss -> V.map ((newFaces i) . fst) ss) sortedSimplices -      sortBoundaries = V.map (V.map (\(i, v, f) -> (i, v, quicksort (\a b -> a < b) f)))--  in (numVerts, sortBoundaries $ sortFiltration $ --sort the simplices by filtration index+  in (numVerts, sortFiltration $ --sort the simplices by filtration index       calcIndices maxIndex (L.tail scales) $         V.map (V.map (\(v, f) -> (0, v, f))) $ simplices) @@ -212,19 +210,18 @@ persistentHomology :: Filtration -> [[BarCode]] persistentHomology (numVerts, allSimplices) =   let-      --Union minus intersection of ordered vectors.+      --union minus intersection       uin :: Ord a => Vector a -> Vector a -> Vector a       u `uin` v =-        let len = V.length v-            findAndInsert i elem vec-              | i == len  = vec `snoc` elem-              | elem == x = (V.take i vec) V.++ (V.drop i1 vec)-              | elem >  x = (V.take i vec) V.++ (elem `cons` (V.drop i vec))-              | otherwise = findAndInsert i1 elem vec-              where x = vec ! i; i1 = i + 1+        let findAndInsert elem vec =+              let (vec1, vec2) = biFilter (\x -> x > elem) vec+              in+                if V.null vec2 then vec `snoc` elem+                else if elem == V.head vec2 then vec1 V.++ V.tail vec2+                else vec1 V.++ (elem `cons` vec2)         in           if V.null u then v-          else (V.tail u) `uin` (findAndInsert 0 (V.head u) v)+          else (V.tail u) `uin` (findAndInsert (V.head u) v)                  removeUnmarked marked = V.filter (\x -> existsVec (\y -> y == x) marked) @@ -281,15 +278,15 @@        verts = 0 `range` (numVerts - 1) -  in L.map (L.filter (\(a,b) -> b /= Just a)) $ makeInfiniteBarCodes $ makeFiniteBarCodes 1 (V.length allSimplices) [fstCodes] (verts `cons` (fstMarked `cons` V.empty)) (fstSlots `cons` V.empty)+  in makeInfiniteBarCodes $ makeFiniteBarCodes 1 (V.length allSimplices) [fstCodes] (verts `cons` (fstMarked `cons` V.empty)) (fstSlots `cons` V.empty)  {- |   Return the maximum of minimum distances bewteen the bar codes.   It's important to note that the function isn't "unsafe" in the sense that it will throw an exception,   it will just give you a distance regardless of whether or not there is the same number of barcodes is in each list. -}-bottelNeckDistance :: [BarCode] -> [BarCode] -> Extended Double-bottelNeckDistance diagram1 diagram2 =+bottleNeckDistance :: [BarCode] -> [BarCode] -> Extended Double+bottleNeckDistance diagram1 diagram2 =   let v1 = V.fromList diagram1       v2 = V.fromList diagram2 @@ -302,8 +299,8 @@   in foldRelation (<) $ V.map (\p -> foldRelation (>) $ V.map (metric p) v2) v1  -- |  Get's all the bottle neck distances; a good way to determine the similarity of the topology of two filtrations.-bottelNeckDistances :: [[BarCode]] -> [[BarCode]] -> [Extended Double]-bottelNeckDistances diagrams1 diagrams2 =+bottleNeckDistances :: [[BarCode]] -> [[BarCode]] -> [Extended Double]+bottleNeckDistances diagrams1 diagrams2 =   let d = (L.length diagrams1) - (L.length diagrams2)   in     if d >= 0 then (L.zipWith bottelNeckDistance diagrams1 diagrams2) L.++ (L.replicate d Infinity)@@ -311,8 +308,8 @@   -- | If the number of barcodes is the same, return the maximum of minimum distances bewteen the bar codes. Otherwise return nothing.-safeBottelNeckDistance :: [BarCode] -> [BarCode] -> Maybe (Extended Double)-safeBottelNeckDistance diagram1 diagram2 =+safeBottleNeckDistance :: [BarCode] -> [BarCode] -> Maybe (Extended Double)+safeBottleNeckDistance diagram1 diagram2 =   if L.length diagram1 /= L.length diagram2 then Nothing   else     let v1 = V.fromList diagram1@@ -327,8 +324,8 @@     in Just $ foldRelation (<) $ V.map (\p -> foldRelation (>) $ V.map (metric p) v2) v1  -- |  Safely get all the bottle neck distances; a good way to determine the similarity of the topology of two filtrations.-safeBottelNeckDistances :: [[BarCode]] -> [[BarCode]] -> [Maybe (Extended Double)]-safeBottelNeckDistances diagrams1 diagrams2 =+safeBottleNeckDistances :: [[BarCode]] -> [[BarCode]] -> [Maybe (Extended Double)]+safeBottleNeckDistances diagrams1 diagrams2 =   let d = (L.length diagrams1) - (L.length diagrams2)   in     if d >= 0 then (L.zipWith safeBottelNeckDistance diagrams1 diagrams2) L.++ (L.replicate d Nothing)