Safe Haskell | None |
---|---|
Language | Haskell2010 |
TimeSeries library
- data DataPoint a
- data Series a
- dpIndex :: DataPoint a -> UTCTime
- dpValue :: DataPoint a -> a
- emptySeries :: Series a
- tsSeries :: [Integer] -> [a] -> Series a
- series :: [(UTCTime, a)] -> Series a
- toList :: Series a -> [(UTCTime, a)]
- values :: Series a -> [a]
- rolling :: TimeResolution -> ([a] -> b) -> Series a -> Series b
- resample :: Fractional a => UTCTime -> TimeResolution -> Series a -> Series a
- size :: Series a -> Int
- slice :: UTCTime -> UTCTime -> Series a -> Series a
- valueAt :: UTCTime -> Series a -> Maybe a
- mean :: Fractional a => Series a -> a
- std :: Floating a => Series a -> a
- variance :: Floating a => Series a -> a
- data TimeResolution
- days :: Integer -> TimeResolution
- months :: Integer -> TimeResolution
- nextTime :: TimeResolution -> UTCTime -> UTCTime
- seconds :: Int -> TimeResolution
- years :: Integer -> TimeResolution
- data HasHeader
- loadCSV :: HasHeader -> (Text -> UTCTime) -> FilePath -> IO (Series Double)
- saveCSV :: Series Double -> FilePath -> IO ()
Series datatype
Data points is a time indexed value
Data structure for holding Series. Implementation should be hidden so it can be changed in the future
Create series
emptySeries :: Series a Source #
Create empty series.
:: [Integer] | List of index value given as number of seconds |
-> [a] | List of value |
-> Series a | Created Series |
Create time series from timestamps and values
seriesFromSeconds [1, 2, 3] [41.3, 52.22, 3.0] == Series [DP 1970-01-01 00:00:01 UTC 2.3,DP 1970-01-01 00:00:02 UTC 4.5]
Conversion between types
Selecting data from series
:: TimeResolution | Window size |
-> ([a] -> b) | Function applied to each window |
-> Series a | Input Series |
-> Series b | Converted Series |
Apply rolling window to create a new Series. Rolling window is also called Sliding Window.
:: Fractional a | |
=> UTCTime | Starting time |
-> TimeResolution | Resampling resolution |
-> Series a | Input series |
-> Series a | Resampled series |
Resample Series.
size :: Series a -> Int Source #
Get series size. Complexity O(n)
size (Series [DP 1 41.3, DP 2 52.22, DP 3 3.0]) == 3
:: UTCTime | Start time (inclusive) |
-> UTCTime | End time (inclusive) |
-> Series a | Input series |
-> Series a | Sliced Series |
Return series subset. Complexity O(n)
slice (Series [DP 1 41.3, DP 2 52.22, DP 3 3.0]) 2 3 == Series [DP 2 52.22, DP 3 3.0] slice (Series [DP 1 41.3, DP 2 52.22, DP 3 3.0]) 5 23 == Series []
Return data point value at given index Complexity O(n)
valueAt (Series [DP 1 41.3, DP 2 52.22, DP 3 3.0]) 2 == Just 52.22 valueAt (Series [DP 1 41.3, DP 2 52.22, DP 3 3.0]) 5 == Nothing
mean :: Fractional a => Series a -> a Source #
Return Time Series mean
data TimeResolution Source #
TimeResolution is for holding time periods which can't easy be translated to number of seconds For example day doesn't always have 86400 and month have different number of days. So if we want to define 1 month period we can't use DiffTime for it.
days :: Integer -> TimeResolution Source #
Create Time Resolution from days
months :: Integer -> TimeResolution Source #
Create Time Resolution from months
seconds :: Int -> TimeResolution Source #
Create Time Resolution from seconds
years :: Integer -> TimeResolution Source #
Create Time Resolution from years