h*T5R      !"#$%&'()*+,-./0123456789:;<=>?@A0.4.0.0(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-Inferred9:;BCDEFGHIJKLMNOPQRSTU(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-Inferred (7<&J uncertainRepresents an independent experimental value centered around a mean value with "inherent" and independent uncertainty.?Mostly useful due to its instances of numeric typeclasses like V, W, etc., which allows you to add and multiply and apply arbitrary numerical functions to them and have the uncertainty propagate appropriately. You can also lift arbitrary (sufficiently polymorphic) functions with , ,  and family. ghci> let x = 1.52 9 0.07 ghci> let y = 781.4 +/- 0.3 ghci> let z = 1.53e-1 `withPrecision' 3 ghci> cosh x 2.4 +/- 0.2 ghci> exp x / z * sin (y ** z) 10.9 +/- 0.9 ghci> pi + 3 * logBase x y 52 +/- 5 Uncertaintly is properly propagated according to the second-degree taylor series approximations of the applied functions. However, if the higher-degree terms are large with respect to to the means and variances of the uncertain values, these approximations may be inaccurate.Can be created with ; to represent an "exact" measurement with no uncertainty,  and . to specify a standard deviation as a range,  , to specify through decimal precision, and  to specify with a variance. Can also be inferred from a list of samples with  7.13  0.05 91800 +/- 100 12.5 `withVar' 0.36  7.9512 81.42 `withPrecision'5 4 7 :: Uncertain Double 9.18 :: Uncertain Double  [12.5, 12.7, 12.6, 12.6, 12.5] Can be deconstructed with , the pattern synonym/pseudo-constructor which matches on the mean and a standard deviation (supported on GHC 7.8+, with bidirectional constructor functionality supported on GHC 7.10+). You can also access properties with , , ,  ,  ,  , etc.It's important to remember that each "occurrence" represents a unique independent sample, so: ghci> let x = 15 = 2 in x + x 30 +/- 3 ghci> let x = 15 +/- 2 in x*2 30 +/- 4 x + x does not represent adding the same sample to itself twice, it represents  independently& sampling two values within the range 15 +/- 2 and adding them together. In general, errors and deviations will cancel each-other out, leading to a smaller uncertainty. However, x*2 represents taking one sample and multiplying it by two. This yields a greater uncertainty, because errors and deviations are amplified.Also be aware that the X instance "normalizes" the result, and won't show any mean/central point to a decimal precision smaller than the uncertainty, rounding off the excess.Y uncertainmaintained to be positive! uncertainPattern match on an 9 with its central value and its standard deviation (see  for clarification).Can also be used to  construct an , identically as .Note: Only supported on GHC 7.8 and above. Bidirectional functionality (to allow use as a constructor) only supported on GHC 7.10 and above. uncertain#Get the mean (central) value of an . uncertainGet the variance of the uncertainty of an , proportional to the square of "how uncertain" a value is. Is the square of . uncertainGet the standard deviation of the uncertainty of an ., proportional to "how uncertain" a value is.Very informally, it can be thought of as the interval above and below the mean that about 68% of sampled values will fall under after repeated sampling, or as the range that one is 68% sure the true value is within.Is the square root of . uncertain Create an ' with an exact value and 0 uncertainty. uncertain Create an  around a central value and a given "range" of uncertainty. The range is interpreted as the standard deviation of the underlying random variable. Might be preferrable over 0 because it is more general (doesn't require a Z$ constraint) and looks a bit nicer.See  for more details. uncertain Create an  around a central value, specifying its uncertainty with a given variance. The variance is taken to be proportional to the square of the range of uncertainty. See  for more details.-"Negative variances" are treated as positive. uncertain Infer an " from a given list of independent samples4 of an underlying uncertain or random distribution.  uncertainRetrieve both the mean (central) value and the underlying variance of an  together.  uMeanVar D  &&&   uncertainRetreve both the mean (central) value and the underlying standard deviation of an  together. (See  for more details)  uMeanStd D  &&&   uncertain:Retrieve the "range" of the underlying distribution of an , derived from the standard deviation, where which approximly 68% of sampled values are expected to occur (or within which you are 68% certain the true value is). $uRange (x +/- dx) D (x - dx, x + dx)  uncertainLike  , except takes a number of "digits" of precision in the desired numeric base. For example, in base 2, takes the number of bits of precision.   D withPrecisionAtBase 10  uncertain Create an  about a given approximate central value, with the given number of digits of precision (in decimal notation). 5.21   3 D 5.21  0.01 uncertainLike 7, but takes a numerical base to round with respect to.  D uNormalizeAtBase 10 uncertainAttempts to "normalize" an . Rounds the uncertainty (the standard deviation) to one digit of precision, and rounds the central moment up to the implied precision.,For example, it makes no real sense to have 542.185433 +/- 83.584, because the extra digits of  542.185433 past the tens place has no meaning because of the overpowering uncertainty. Normalizing this results in  540 +/- 80.Note that the X instance for ( normalizes values before showing them. uncertainLike [ for ), but does not normalize the value (see )) before showing. See documentation for [7 for more information on how this is meant to be used. uncertainLike \ for ), but does not normalize the value (see ) before showing. \ D uShow .  uncertainLifts a multivariate numeric function on a container (given as an  f a -> a) to work on a container of s. Correctly propagates the uncertainty according to the second-order (multivariate) taylor expansion of the function. Note that if the higher-degree taylor series terms are large with respect to the means and variances, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ], ^, _, etc. (ghci> liftUF (\[x,y,z] -> x*y+z) [12.2 + - 0.5, 56 +- 2, 0.12 +/- 0.08] 680 +/- 40  uncertain!Lifts a numeric function over an . Correctly propagates the uncertainty according to the second-order taylor expansion expansion of the function. Note that if the higher-degree taylor series terms are large with respect to the mean and variance, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ^, `, a, etc. 9ghci> liftU (\x -> log x ^ 2) (12.2 +/- 0.5) 6.3 +/- 0.2  uncertain1Lifts a two-argument (curried) function over two s. Correctly propagates the uncertainty according to the second-order (multivariate) taylor expansion expansion of the function. Note that if the higher-degree taylor series terms are large with respect to the mean and variance, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ], _, b, etc. #ghci> liftU2 (\x y -> x**y) (13.5 +- 0.1) (1.64 +- 0.08) 70 +/- 10  uncertain5Lifts a three-argument (curried) function over three  s. See  and  for more details. uncertain3Lifts a four-argument (curried) function over four  s. See  and  for more details. uncertain3Lifts a five-argument (curried) function over five  s. See  and  for more details. uncertainThe exact value uncertainThe mean or central value uncertain4The standard deviation of the underlying uncertainty uncertainThe mean or central value uncertain*The variance of the underlying uncertainty  uncertain/The base to determine precision with respect to uncertainThe approximate value of the  uncertain+The number of "digits" of precision to take  uncertainThe approximate value of the  uncertain+The number of "digits" of precision to take uncertain%The base to normalize with respect to uncertain'Function on container of values to lift uncertain Container of s to apply the function to uncertainFunction on values to lift uncertain to apply the function to    66(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-Inferred )*69? $ uncertainThe $ monad allows us to keep track of correlated and non-independent samples. It fixes a basic "failure" of the 0 type, which can't describe correlated samples.-For example, consider the difference between: ghci> sum $ replicate 10 (12.5 4 0.8) 125 +/- 3 ghci> 10 * (12.5 +/- 0.8) 125 +/- 8 The first one represents the addition of ten independent samples, whose errors will in general cancel eachother out. The second one represents sampling once and multiplying it by ten, which will amplify any error by a full factor of 10. See how the $( monad expresses the above computations: ghci> evalCorr $ do x <-  sampleUncert $ 12.5  0.8 y1 <-  resolveUncert $ sum (replicate 10 x) y2 <- resolveUncert $ 10 * x return (y1, y2) (125 +/- 8, 125 +/- 8) ghci> evalCorr# $ do xs <- replicateM 10 ( sampleUncert (12.5 +/- 0.8))  resolveUncert $ sum xs 125 +/- 3 The first example samples once and describes operations on the single sample; the second example samples 10 times with  replicateM and sums all of the results.?Things are more interesting when you sample multiple variables: ghci> evalCorr $ do x <-  sampleUncert $ 12.5  0.8 y <- sampleUncert $ 15.9 +/- 0.5 z <- sampleUncert $ 1.52 +/- 0.07 let k = y ** x  resolveUncert$ $ (x+z) * logBase z k 1200 +/- 200 The first parameter is a dummy phantom parameter used to prevent %,s from leaking out of the computation (see evalCorr). The second parameter is the numeric type of all samples within the description (for example, if you ever sample an  c, the second parameter wil be c). The third parameter is the result type of the computation -- the value the $ is describing.% uncertainRepresents a single sample (or a value calculated from samples) within the $# monad. These can be created with  sampleUncert,  sampleExact, and ', or made by combinining others with its numeric typeclass instances (like V>) or its functions lifting arbitrary numeric functions (like )). These keep track of inter-correlations between sources, and if you add together two %8s that are correlated, their results will reflect this.Can be "resolved" into the uncertain value they represent using  resolveUncert.?Note that these are parameterized by a dummy phantom parameter s/ so that they can't be "evaluated" out of the $ they live in with evalCorr. Note that a % s a) can only ever meaningfully "exist" in a $ s a+, meaning that the all samples within that $ are of the same type.d uncertainUnsafe function to bypass the universal qualification guard for returning %s from $s.& uncertainLifts a multivariate numeric function on a container (given as an  f a -> a) to work on a container of %s. Correctly propagates the uncertainty according to the second-order (multivariate) taylor expansion of the function, and properly takes into account and keeps track of all inter-correlations between the % samples. Note that if the higher-degree taylor series terms are large with respect to the means and variances, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ], ^, _, etc. ghci> evalCorr $ do x <-  sampleUncert $ 12.5  0.8 y <- sampleUncert $ 15.9 +/- 0.5 z <- sampleUncert $ 1.52 +/- 0.07  resolveUncert $ liftCF (\[a,b,c] -> (a+c) * logBase c (b**a)) x y z 1200 +/- 200 ' uncertain Creates a %> representing a completely independent sample from all other %#s containing the exact value given.( uncertain:Lifts a numeric function over the sample represented by a %. Correctly propagates the uncertainty according to the second-order taylor expansion expansion of the function. Note that if the higher-degree taylor series terms are large with respect to the mean and variance, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ^, `, a, etc. ghci> evalCorr $ do x <-  sampleUncert $ 12.5 6 0.8 y <- sampleUncert $ 15.9 +/- 0.5  resolveUncert0 $ liftC (\z -> log z ^ 2) (x + y) 11.2 +/- 0.2 ) uncertainLifts a two-argument (curried) function over the samples represented by two %s. Correctly propagates the uncertainty according to the second-order (multivariate) taylor expansion expansion of the function, and properly takes into account and keeps track of all inter-correlations between the % samples. Note that if the higher-degree taylor series terms are large with respect to the mean and variance, this approximation may be inaccurate.Should take any function sufficiently polymorphic over numeric types, so you can use things like ], _, b, etc. ghci> evalCorr $ do x <-  sampleUncert $ 12.5 6 0.8 y <- sampleUncert $ 15.9 +/- 0.5  resolveUncert5 $ liftC2 (\a b -> log (a + b) ^ 2) x y 11.2 +/- 0.2 * uncertainLifts a three-argument (curried) function over the samples represented by three %s. See ) and & for more details.+ uncertainLifts a four-argument (curried) function over the samples represented by four %s. See ) and & for more details., uncertainLifts a five-argument (curried) function over the samples represented by five %s. See ) and & for more details.& uncertain'Function on container of values to lift uncertain Container of %! samples to apply the function to( uncertainFunction on values to lift uncertain% sample to apply the function to%defgh$&'()*+,i(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-InferredEB- uncertain#Evaluates the value described by a $ monad, taking into account inter-correlations between samples.Takes a universally qualified $, which should not affect usage. See the examples in the documentation for $. The univeral qualification is mostly a type system trick to ensure that you aren't allowed to ever use - to evaluate a %.. uncertainGenerate a sample in $ from an . value, independently from all other samples.Note that you can only sample  a s within a $ s a4, meaning that all other "sampled" values are also as./ uncertainGenerate an exact sample in $> with zero uncertainty, independently from all other samples.=Not super useful, since you can do something equivalent with ' or the numeric instances: sampleExact x D return (' x) sampleExact 10 D return 10 +But is provided for completeness alongside ..$Note that you can exactly sample an a within a $ s a4, meaning that all other "sampled" values are also as.0 uncertainResolve an  from a % using its potential multiple samples and sample sources, taking into account inter-correlations between %s and samples.Note that if you use . on the result, the new sample will be treated as something completely independent. Usually this should only be used as the "exit point" of a $ description. $-%./'0()*+,& $-%./'0()*+,&(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-InferredIr1 uncertainA %5 specialized to work in an "interactive" context, in ghci or j.2 uncertainGenerate a sample in j from an  c. value, independently from all other samples.3 uncertainGenerate an exact sample in j> with zero uncertainty, independently from all other samples.=Not super useful, since you can do something equivalent with ' or the numeric instances: sampleExact x D return (' x) sampleExact 10 D return 10 +But is provided for completeness alongside 2.4 uncertainResolve an  from a 1 using its potential multiple samples and sample sources, taking into account inter-correlations between 1s and samples.Note that if you use 2 on the result, the new sample will be treated as something completely independent. Usually this should only be used as the "final value" of your computation or exploration. %123'4()*+,& %123'4()*+,&(c) Justin Le 2016BSD3 justin@jle.im experimental non-portable Safe-Inferred(Q 5 uncertainSample a random c( from the distribution specified by an  c. x +/- dx is treated as a random variable whose probability density is the normal distribution with mean x and standard deviation dx.6 uncertain!Lifts a numeric function over an 3 using a Monte Carlo simulation with 1000 samples.  ghci> g <- k? ghci> MC.liftU (\x -> log x ^ 2) (12.2 +/- 0.5) g 6.3 +/- 0.2 7 uncertainLifts a multivariate numeric function on a container (given as an  f a -> a) to work on a container of 4s using a Monte Carlo simulation with 1000 samples.  ghci> g <- k+ ghci> M.liftUF (\[x,y,z] -> x*y+z) [12.2 + - 0.5, 56 +!- 2, 0.12 +/- 0.08] g 680 +/- 40 8 uncertain1Lifts a two-argument (curried) function over two 4s using a Monte Carlo simulation with 1000 samples.  ghci> g <- k' ghci> MC.liftU2 (\x y -> x**y) (13.5 +- 0.1) (1.64 +- 0.08) 70 +/- 20 9 uncertain5Lifts a three-argument (curried) function over three  s. See 8 and 7 for more details.: uncertain3Lifts a four-argument (curried) function over four  s. See 8 and 7 for more details.; uncertain3Lifts a five-argument (curried) function over five  s. See 8 and 7 for more details.< uncertainLike 6, but allows you to specify the number of samples to run the Monte Carlo simulation with.= uncertainLike 7, but allows you to specify the number of samples to run the Monte Carlo simulation with.> uncertainLike 8, but allows you to specify the number of samples to run the Monte Carlo simulation with.? uncertainLike 9, but allows you to specify the number of samples to run the Monte Carlo simulation with.@ uncertainLike :, but allows you to specify the number of samples to run the Monte Carlo simulation with.A uncertainLike ;, but allows you to specify the number of samples to run the Monte Carlo simulation with. 5689:;7<>?@A= 5689:;7<>?@A=      !"#$%&'()*+,-./01234567896786:;<=>?@@AABBCCDDEFGHIJKLMNOPQORSOTUVOWXOTYOTZOP[OW\OW]OW^OP_OW`abcdefghiabjklm(uncertain-0.4.0.0-I4qcnFHel30130wOnR3WTsNumeric.UncertainNumeric.Uncertain.Correlated(Numeric.Uncertain.Correlated.InteractiveNumeric.Uncertain.MonteCarlo uncertain Data.Hople%Numeric.Uncertain.Correlated.InternalUncert:+/-uMeanuVaruStdexact+/-withVar fromSamplesuMeanVaruMeanStduRangewithPrecisionAtBase withPrecisionuNormalizeAtBase uNormalize uShowsPrecuShowliftUFliftUliftU2liftU3liftU4liftU5$fRealFloatUncert$fRealFracUncert $fRealUncert $fOrdUncert $fEqUncert$fFloatingUncert$fFractionalUncert $fNumUncert $fShowUncert $fDataUncert$fGenericUncert$fGeneric1TYPEUncertCorrCVarliftCFconstCliftCliftC2liftC3liftC4liftC5evalCorr sampleUncert sampleExact resolveUncertCVarIOliftU'liftUF'liftU2'liftU3'liftU4'liftU5'H1H2H3H4H5curryH1curryH2curryH3curryH4curryH5 uncurryH1 uncurryH2 uncurryH3 uncurryH4 uncurryH5baseGHC.NumNumGHC.Real FractionalGHC.ShowShow_uVar GHC.FloatFloating showsPrecshow*sqrtatan2sinnegate**ghc-prim GHC.TypesDouble dephantomCorrFFunGenRei corrToStateIO*mwc-random-0.15.1.0-7UasCCadMZ94RdLWheHwC1System.Random.MWCcreate