probability 0.2.3.1 → 0.2.4
raw patch · 4 files changed
+26/−10 lines, 4 filesdep ~transformersPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: transformers
API changes (from Hackage documentation)
+ Numeric.Probability.Percentage: (//*) :: (Ord a, Show a) => Dist a -> (Int, Int) -> IO ()
- Numeric.Probability.Visualize: out0 :: String -> String -> IO ()
+ Numeric.Probability.Visualize: out0 :: FilePath -> String -> IO ()
- Numeric.Probability.Visualize: out1 :: String -> String -> IO ()
+ Numeric.Probability.Visualize: out1 :: FilePath -> String -> IO ()
Files
- probability.cabal +3/−3
- src/Numeric/Probability/Object.hs +2/−0
- src/Numeric/Probability/Percentage.hs +17/−3
- src/Numeric/Probability/Visualize.hs +4/−4
probability.cabal view
@@ -1,5 +1,5 @@ Name: probability-Version: 0.2.3.1+Version: 0.2.4 License: BSD3 License-File: COPYRIGHT Author: Martin Erwig <erwig@eecs.oregonstate.edu>, Steve Kollmansberger@@ -28,7 +28,7 @@ Source-Repository this type: darcs location: http://code.haskell.org/~thielema/probability/- tag: 0.2.3.1+ tag: 0.2.4 Flag splitBase@@ -37,7 +37,7 @@ Library Build-Depends: utility-ht >=0.0.6 && <0.1,- transformers >=0.0.1 && <0.3+ transformers >=0.0.1 && <0.4 If flag(splitBase) Build-Depends: containers >=0.1 && <1,
src/Numeric/Probability/Object.hs view
@@ -12,6 +12,8 @@ and for generating random values according to the distribution. The latter one is of course more efficient and may be used for approximation of the distribution by simulation.++Maybe a better name is @Experiment@. -} module Numeric.Probability.Object where
src/Numeric/Probability/Percentage.hs view
@@ -9,6 +9,8 @@ import Numeric.Probability.Show (showR) import Numeric.Probability.Trace (Trace) +import Data.List.HT (padLeft, )+ import qualified System.Random as Random @@ -22,11 +24,18 @@ showPfix :: (RealFrac prob, Show prob) => Int -> prob -> String-showPfix precision f =+showPfix precision x = if precision==0- then showR 3 (round (f*100) :: Integer)++"%"- else showR (4+precision) (roundRel precision (f*100))++"%"+ then showR 3 (round (x*100) :: Integer) ++ "%"+ else+ let str =+ padLeft '0' (precision+1)+ (show (round (x*10^(precision+2)) :: Integer))+ (int,frac) =+ splitAt (length str - precision) str+ in padLeft ' ' 3 int ++ '.' : frac ++ "%" +{-# DEPRECATED roundRel "was used to implemented showPfix, but is no longer needed for this purpose, and should not be exported anyway, and does not contribute to a safe way to format fixed point values, because the rounded value may not be accurate" #-} roundRel :: (RealFrac a) => Int -> a -> a roundRel p x = let d = 10^p@@ -57,6 +66,11 @@ (//) :: (Ord a, Show a) => Dist a -> Int -> IO () (//) x prec = putStr (Dist.pretty (\(Cons p) -> showPfix prec p) x) +(//*) :: (Ord a, Show a) => Dist a -> (Int,Int) -> IO ()+(//*) x (prec,width) = putStr $ flip Dist.pretty x $+ \(Cons p) ->+ showPfix prec p ++ " " +++ replicate (round (p * fromIntegral width)) '*'
src/Numeric/Probability/Visualize.hs view
@@ -238,8 +238,8 @@ vec :: Show a => [a] -> String vec xs0 = "c"++asTuple show xs0 -out0 :: String -> String -> IO ()-out0 f s = writeFile (f) (s++"\n")+out0 :: FilePath -> String -> IO ()+out0 f s = writeFile f (s++"\n") -out1 :: String -> String -> IO ()-out1 f s = appendFile (f) (s++"\n")+out1 :: FilePath -> String -> IO ()+out1 f s = appendFile f (s++"\n")