!Ӱ.      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Safe 8>DHVb0& numhask-spaceRPos suggests where points should be placed in forming a grid across a field space. numhask-spaceinclude boundaries numhask-spacedon't include boundaries numhask-spaceinclude the lower boundary numhask-spaceinclude the upper boundary numhask-spaceuse the mid-point of the space numhask-space"a space that can be divided neatly Sspace1 (grid OuterPos s g) == s getUnion (sconcat (Union <$> (gridSpace s g))) == s numhask-space-create equally-spaced elements across a space  numhask-space)create equally-spaced spaces from a space  numhask-space 7https://en.wikipedia.org/wiki/Intersection_(set_theory)  numhask-space a convex hull numhask-space_Space is a continuous range of numbers that contains elements and has an upper and lower value.  a `union` b == b `union` a a `intersection` b == b `intersection` a (a `union` b) `intersection` c == (a `intersection` b) `union` (a `intersection` c) (a `intersection` b) `union` c == (a `union` b) `intersection` (a `union` c) norm (norm a) = norm a a |>| b == b |<| a a |.| singleton a numhask-space#the underlying element in the space numhask-spacelower boundary numhask-spaceupper boundary numhask-space!space containing a single element numhask-spacethe intersection of two spaces numhask-spacethe union of two spaces numhask-spaceNormalise a space so that ;lower a \/ upper a == lower a lower a /\ upper a == upper a numhask-space+create a normalised space from two elements numhask-space4create a space from two elements without normalising numhask-spaceis an element in the space numhask-space'is one space completely above the other numhask-space'is one space completely below the other numhask-space$is a space contained within another? 5(a `union` b) `contains` a (a `union` b) `contains` b numhask-spaceare two spaces disjoint? numhask-space&is an element contained within a space  numhask-spacedistance between boundaries! numhask-space,create a space centered on a plus or minus b" numhask-spacemiddle element of the space# numhask-spaceLproject a data point from one space to another, preserving relative position mproject o n (lower o) = lower n project o n (upper o) = upper n project o n (mid o) = mid n project a a x = x$ numhask-space/the containing space of a non-empty Traversable all $ space1 a `contains` <$> a% numhask-spaceFlift a monotone function (increasing or decreasing) over a given space& numhask-space a small space' numhask-space widen a space( numhask-spacewiden by a small amount) numhask-space&Scale a Space. (scalar multiplication)* numhask-spaceMove a Space. (scalar addition)+  !"#$%&'()*33777!6Safe7Dbh + numhask-space(whether to include lower and upper times. numhask-spacea step in time5 numhask-spaceparse text as per iso8601:set -XOverloadedStrings,let t0 = parseUTCTime ("2017-12-05" :: Text)t0Just 2017-12-05 00:00:00 UTC numhask-spaceadd a TimeGrain to a UTCTime:addGrain (Years 1) 5 (UTCTime (fromGregorian 2015 2 28) 0)2020-02-29 00:00:00 UTC;addGrain (Months 1) 1 (UTCTime (fromGregorian 2015 2 28) 0)2015-03-31 00:00:00 UTC:addGrain (Hours 6) 5 (UTCTime (fromGregorian 2015 2 28) 0)2015-03-01 06:00:00 UTCJaddGrain (Seconds 0.001) (60*1000+1) (UTCTime (fromGregorian 2015 2 28) 0)2015-02-28 00:01:00.001 UTC6 numhask-space0compute the floor UTCTime based on the timegrain9floorGrain (Years 5) (UTCTime (fromGregorian 1999 1 1) 0)1995-12-31 00:00:00 UTC<floorGrain (Months 3) (UTCTime (fromGregorian 2016 12 30) 0)2016-09-30 00:00:00 UTC:floorGrain (Days 5) (UTCTime (fromGregorian 2016 12 30) 1)2016-12-30 00:00:00 UTCTfloorGrain (Minutes 15) (UTCTime (fromGregorian 2016 12 30) (fromDouble' $ 15*60+1))2016-12-30 00:15:00 UTCBfloorGrain (Seconds 0.1) (UTCTime (fromGregorian 2016 12 30) 0.12)2016-12-30 00:00:00.1 UTC7 numhask-space2compute the ceiling UTCTime based on the timegrain;ceilingGrain (Years 5) (UTCTime (fromGregorian 1999 1 1) 0)2000-12-31 00:00:00 UTC>ceilingGrain (Months 3) (UTCTime (fromGregorian 2016 12 30) 0)2016-12-31 00:00:00 UTC<ceilingGrain (Days 5) (UTCTime (fromGregorian 2016 12 30) 1)2016-12-31 00:00:00 UTCVceilingGrain (Minutes 15) (UTCTime (fromGregorian 2016 12 30) (fromDouble' $ 15*60+1))2016-12-30 00:30:00 UTCDceilingGrain (Seconds 0.1) (UTCTime (fromGregorian 2016 12 30) 0.12)2016-12-30 00:00:00.2 UTC8 numhask-spaceDates used for time series analysis or attached to charts are often discontinuous, but we want to smooth that reality over and show a continuous range on the axis.The assumption with getSensibleTimeGrid is that there is a list of discountinuous UTCTimes rather than a continuous range. Output is a list of index points for the original [UTCTime] and label tuples, and a list of unused list elements.placedTimeLabelDiscontinuous PosIncludeBoundaries (Just "%d %b") 2 [UTCTime (fromGregorian 2017 12 6) 0, UTCTime (fromGregorian 2017 12 29) 0, UTCTime (fromGregorian 2018 1 31) 0, UTCTime (fromGregorian 2018 3 3) 0]:([(0,"06 Dec"),(1,"31 Dec"),(2,"28 Feb"),(3,"03 Mar")],[])9 numhask-space]A sensible time grid between two dates, projected onto (0,1) with no attempt to get finnicky.placedTimeLabelContinuous PosIncludeBoundaries (Just "%d %b") 2 (UTCTime (fromGregorian 2017 12 6) 0, UTCTime (fromGregorian 2017 12 29) 0)\[(0.0,"06 Dec"),(0.43478260869565216,"16 Dec"),(0.8695652173913043,"26 Dec"),(1.0,"29 Dec")]: numhask-space1compute a sensible TimeGrain and list of UTCTimeshsensibleTimeGrid InnerPos 2 (UTCTime (fromGregorian 2016 12 31) 0, UTCTime (fromGregorian 2017 12 31) 0)T(Months 6,[2016-12-31 00:00:00 UTC,2017-06-30 00:00:00 UTC,2017-12-31 00:00:00 UTC])fsensibleTimeGrid InnerPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)$(Months 6,[2017-06-30 00:00:00 UTC])fsensibleTimeGrid UpperPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)<(Months 6,[2017-06-30 00:00:00 UTC,2017-12-31 00:00:00 UTC])fsensibleTimeGrid LowerPos 2 (UTCTime (fromGregorian 2017 1 1) 0, UTCTime (fromGregorian 2017 12 30) 0)<(Months 6,[2016-12-31 00:00:00 UTC,2017-06-30 00:00:00 UTC]) numhask-space8come up with a sensible TimeGrain over a NominalDiffTime+,-./0123456789:5./0123467:+,-89Safe7DHVbw> numhask-spaceA continuous range over type alet a = Range (-1) 1a Range -1 1VNum instance based on interval arithmetic (with Ranges normalising to lower ... upper)a + a Range -2 2a * a Range -1 1(+1) <$> (Range 1 2) Range 2 3Ranges are very useful in shifting a bunch of numbers from one Range to another. eg project 0.5 from the range 0 to 1 to the range 1 to 4#project (Range 0 1) (Range 1 4) 0.52.5ACreate an equally spaced grid including outer bounds over a Rangegrid OuterPos (Range 0 10) 5[0.0,2.0,4.0,6.0,8.0,10.0]+divide up a Range into equal-sized sectionsgridSpace (Range 0 1) 4=[Range 0.0 0.25,Range 0.25 0.5,Range 0.5 0.75,Range 0.75 1.0]@ numhask-space'a grid for five-digits per limb species2gridSensible OuterPos False (Range (-12.0) 23.0) 6.[-15.0,-10.0,-5.0,0.0,5.0,10.0,15.0,20.0,25.0]A numhask-space,Numeric algebra based on Interval arithmeticB numhask-space!Monoid based on convex hull union>?@>?@Safe7DHVbT numhask-spaceA 2-dim point of a'sAA Point is functorial over both arguments, and is a Num instance.let p = Point 1 1p + p Point 2 2 (2*) <$> p Point 2 2A major reason for this bespoke treatment of a point is that Points do not have maximums and minimums but they form a lattice, and this is useful for folding points to find out the (rectangular) Space they occupy.Point 0 1 /\ Point 1 0 Point 0 0Point 0 1 \/ Point 1 0 Point 1 1V numhask-space2rotate a point by x degrees relative to the originrotate 90 (Point 0 1)Point 1.0 6.123233995736766e-17W numhask-space7Create Points for a formulae y = f(x) across an x rangegridP (**2) (Range 0 4) 4H[Point 0.0 0.0,Point 1.0 1.0,Point 2.0 4.0,Point 3.0 9.0,Point 4.0 16.0]TUVWTUVWNone4567>DHMVbgj numhask-spaceCa rectangular space often representing a 2-dimensional or XY plane.let a = Rect (-1) 1 (-2) 4aRect -1 1 -2 4let (Ranges x y) = ax Range -1 1y Range -2 4fmap (+1) (Rect 1 2 3 4) Rect 2 3 4 5+as a Space instance with Points as Elements7project (Rect 0 1 (-1) 0) (Rect 1 4 10 0) (Point 0.5 1)Point 2.5 -10.0%gridSpace (Rect 0 10 0 1) (Point 2 2)W[Rect 0.0 5.0 0.0 0.5,Rect 0.0 5.0 0.5 1.0,Rect 5.0 10.0 0.0 0.5,Rect 5.0 10.0 0.5 1.0]'grid MidPos (Rect 0 10 0 1) (Point 2 2)=[Point 2.5 0.25,Point 2.5 0.75,Point 7.5 0.25,Point 7.5 0.75]l numhask-spacepattern of Ranges xrange yrangem numhask-space+pattern of Rect lowerx upperx lowery upperyn numhask-space[create a list of points representing the lower left and upper right corners of a rectangle.corners unitRect[Point -0.5 -0.5,Point 0.5 0.5]o numhask-space the 4 cornerscorners4 unitRect=[Point -0.5 -0.5,Point -0.5 0.5,Point 0.5 -0.5,Point 0.5 0.5]p numhask-space5project a Rect from an old Space (Rect) to a new one.^The Space instance of Rect uses Points as Elements, but a Rect can also be a Space over Rects.MprojectRect (Rect 0 1 (-1) 0) (Rect 0 4 0 8) (Rect 0.25 0.75 (-0.75) (-0.25))Rect 1.0 3.0 2.0 6.0q numhask-space Rect additionunitRect `addRect` unitRectRect -1.0 1.0 -1.0 1.0r numhask-spaceRect multiplication unitRect `multRect` Rect 0 2 0 4Rect 0.0 2.0 0.0 4.0s numhask-spaceUa unit Rectangle, with values chosen so that width and height are one and mid is zerounitRect :: Rect DoubleRect -0.5 0.5 -0.5 0.5t numhask-spaceconvex hull union of Rect's!foldRect [Rect 0 1 0 1, unitRect]Just Rect -0.5 1.0 -0.5 1.0u numhask-spaceadd a Point to a RectaddPoint (Point 0 1) unitRectRect -0.5 0.5 0.5 1.5v numhask-spaceXrotate the corners of a Rect by x degrees relative to the origin, and fold to a new RectrotateRect 45 unitRectXRect -0.7071067811865475 0.7071067811865475 -5.551115123125783e-17 5.551115123125783e-17w numhask-spaceUCreate Rects for a formulae y = f(x) across an x range where the y range is Range 0 ygridR (**2) (Range 0 4) 4Z[Rect 0.0 1.0 0.0 0.25,Rect 1.0 2.0 0.0 2.25,Rect 2.0 3.0 0.0 6.25,Rect 3.0 4.0 0.0 12.25]x numhask-space8Create values c for Rects data for a formulae c = f(x,y)8gridF (\(Point x y) -> x * y) (Rect 0 4 0 4) (Point 2 2)m[(Rect 0.0 2.0 0.0 2.0,1.0),(Rect 0.0 2.0 2.0 4.0,3.0),(Rect 2.0 4.0 0.0 2.0,3.0),(Rect 2.0 4.0 2.0 4.0,9.0)]y numhask-space8convert a ratio (eg x:1) to a Rect with a height of one.aspect 2Rect -1.0 1.0 -0.5 0.5z numhask-spaceconvert a Rect to a ratioratio (Rect (-1) 1 (-0.5) 0.5)2.0{ numhask-spaceiNumeric algebra based on interval arithmetioc for addition and unitRect and projection for multiplicationjklmnopqrstuvwxyzjkmlnopqrstuvwxyzNone.Db0  numhask-spaceWhether or not to ignore unders and overs. If overs and unders are dealt with, IncludeOvers supplies an assumed width for the outer buckets. numhask-spaceThis Histogram is a list of contiguous boundaries (a boundary being the lower edge of one bucket and the upper edge of another), and a value (usually a count) for each bucket, represented here as a map?Overs and Unders are contained in key = 0 and key = length cuts numhask-space)Fill a Histogram using pre-specified cutsfill [0,50,100] [1..100]JHistogram {cuts = [0.0,50.0,100.0], values = fromList [(1,50.0),(2,50.0)]} numhask-space7find the index of the bucket the value is contained in. numhask-spaceNMake a histogram using n equally spaced cuts over the entire range of the dataregular 4 [0..100]nHistogram {cuts = [0.0,25.0,50.0,75.0,100.0], values = fromList [(0,1.0),(1,25.0),(2,25.0),(3,25.0),(4,25.0)]} numhask-spaceTransform a Histogram to Rects*makeRects IgnoreOvers (regular 4 [0..100])a[Rect 0.0 25.0 0.0 0.25,Rect 25.0 50.0 0.0 0.25,Rect 50.0 75.0 0.0 0.25,Rect 75.0 100.0 0.0 0.25] numhask-spaceapprox regular n-quantilesregularQuantiles 4 [0..100][0.0,24.75,50.0,75.25,100.0] numhask-space#one-pass approximate quantiles fold numhask-space6take a specification of quantiles and make a Histogram?fromQuantiles [0,0.25,0.5,0.75,1] (regularQuantiles 4 [0..100])hHistogram {cuts = [0.0,24.75,50.0,75.25,100.0], values = fromList [(1,0.25),(2,0.25),(3,0.25),(4,0.25)]} numhask-space.normalize a histogram so that sum values = onefreq $ fill [0,50,100] [1..100]HHistogram {cuts = [0.0,50.0,100.0], values = fromList [(1,0.5),(2,0.5)]}NoneDbb  !"#$%&'()*+,-./0123456789:>?@TUVWjklmnopqrstuvwxyz+   "#$ !%&'()*      !"#$%&'()*+,-./0123456789:;<=>?@ABCDDEFGHIJKLMNOPQRSTUVWXYYZ[\]^_`abcdefghijklmnopnqrstuvwxyz{|}~*numhask-space-0.5.0-FUBX5Wpr3dK8FcMTBgSolq NumHask.SpaceNumHask.Space.TimeNumHask.Space.RangeNumHask.Space.PointNumHask.Space.RectNumHask.Space.HistogramNumHask.Space.TypesPosOuterPosInnerPosLowerPosUpperPosMidPos FieldSpaceGridgrid gridSpace IntersectiongetIntersectionUniongetUnionSpaceElementlowerupper singleton intersectionunionnorm...>.<|.||>||<|containsdisjointmemberOfwidth+/-midprojectspace1monotoneepswidenwidenEpsscalemovePosDiscontinuous PosInnerOnlyPosIncludeBoundaries TimeGrainYearsMonthsDaysHoursMinutesSeconds parseUTCTime floorGrain ceilingGrainplacedTimeLabelDiscontinuousplacedTimeLabelContinuoussensibleTimeGrid$fShowTimeGrain $fEqTimeGrain$fGenericTimeGrainRange gridSensible $fNumRange$fSemigroupRange$fFieldSpaceRange $fSpaceRange$fLatticeRange$fRepresentableRange$fDistributiveRange$fTraversable1Range$fTraversableRange$fFoldable1Range$fFoldableRange$fApplicativeRange $fApplyRange$fFunctorRange $fShow1Range $fEq1Range $fShowRange $fEqRange$fGenericRangePointrotategridP$fLatticePoint$fRepresentablePoint$fDistributivePoint$fFractionalPoint $fNumPoint$fBoundedPoint $fMonoidPoint$fSemigroupPoint$fTraversablePoint$fFoldablePoint $fMonadPoint$fApplicativePoint $fShow1Point $fEq1Point$fFunctorPoint $fShowPoint $fEqPoint$fGenericPointRectRect'Rangescornerscorners4 projectRectaddRectmultRectunitRectfoldRectaddPoint rotateRectgridRgridFaspectratio $fNumRect$fFieldSpaceRect $fSpaceRect$fSemigroupRect$fRepresentableRect$fDistributiveRect $fShowRect$fEqRect $fFunctorRect$fApplicativeRect$fFoldableRect$fTraversableRect $fGenericRect DealOvers IgnoreOvers IncludeOvers HistogramcutsvaluesfillcutIregular makeRectsregularQuantiles quantileFold fromQuantilesfreq$fShowHistogram $fEqHistogramaddGrainstepSensibleTime